1
\$\begingroup\$

I'm creating a responsive page with bootstrap. I tested my code with my browser (Firefox and Chrome) and it works. Is the code clean or is there a better way to code it?

<div class="col-xs-12 col-sm-6 col-md-4" style="margin-top: 2%;">
 <div class="adress">
 <ul style="list-style: none; padding-left: 0">
 <li><strong><%= name %></strong></li>
 <li><%= adresse %></li>
 </ul>
 </div>
 <div>
 <button class="btn btn-default btn-block" type="submit">Choose Address</button>
 </div>
 <div class="row">
 <div style="margin-top: 5%">
 <div class="col-xs-6 col-sm-6 col-md-6">
 <button class="btn-xs btn-default btn-block" id="editBtn" type="submit">Edit</button>
 </div>
 <div class="col-xs-6 col-sm-6 col-md-6">
 <button class="btn-xs btn-warning btn-block" id="delBtn" type="submit">Delete</button>
 </div>
 </div>
 </div>
</div>
Phrancis
20.5k6 gold badges69 silver badges155 bronze badges
asked Dec 13, 2016 at 6:58
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

This is a small piece of code but few things I'm going to highlight here

  • When using the col class, it's best practice to have this class under a row class. This creates a grid structure e.g
 <div class="row">
 <div class="col-sm-4">.col-sm-4</div>
 <div class="col-sm-4">.col-sm-4</div>
 <div class="col-sm-4">.col-sm-4</div>
 </div>
  • One thing to note here is that in bootstrap grid structure the total number of columns you can have is 12 . You can read more on that Bootstrap Grids . So these lines defines more than 12 columns and it's abusing bootstrap usage
<div class="col-xs-12 col-sm-6 col-md-4" style="margin-top: 2%;">
 <div class="col-xs-6 col-sm-6 col-md-6">
  • I can see some Inline css declarations floating about, there isn't anything bad with that but it becomes cumbersome when you have many div's in your page. I suggest defining your css in an external stylesheet

I hope this helps

answered Dec 13, 2016 at 22:14
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.