I just started using Twitter Bootstrap, and I have a question about how to best add a border to a parent element?
for instance, if I have
<div class="main-area span12"> <div class="row"> <div class="span9"> //Maybe some description text </div> <div class="span3"> //Maybe a button or something </div> </div> </div>
If I apply a border like so:
.main-area { border: 1px solid #ccc; }
The grid system will break and kick span3
down to the next row because of the added width of the border......Is there a good way to be able to add things like borders or padding to the parent <div>
s like this?
. border-right : This class adds a border on the right of the element. . border-bottom : This class adds a border on the bottom of the element.
Use the border-top-0 class to remove the top border from an element.
You can just add the same rule border-radius: 20% to the card element.
If you look at Twitter's own container-app.html demo on GitHub, you'll get some ideas on using borders with their grid.
For example, here's the extracted part of the building blocks to their 940-pixel wide 16-column grid system:
.row { zoom: 1; margin-left: -20px; } .row > [class*="span"] { display: inline; float: left; margin-left: 20px; } .span4 { width: 220px; }
To allow for borders on specific elements, they added embedded CSS to the page that reduces matching classes by enough amount to account for the border(s).
For example, to allow for the left border on the sidebar, they added this CSS in the <head>
after the the main <link href="../bootstrap.css" rel="stylesheet">
.
.content .span4 { margin-left: 0; padding-left: 19px; border-left: 1px solid #eee; }
You'll see they've reduced padding-left
by 1px
to allow for the addition of the new left border. Since this rule appears later in the source order, it overrides any previous or external declarations.
I'd argue this isn't exactly the most robust or elegant approach, but it illustrates the most basic example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With