css - How to use Twitter Bootstrap correctly ( adding styles )? -
i trying figure out bulletproof way of using bootstrap correctly. here example:
<style><!-- own class in separate stylesheet --> .myclass {border:1px solid #666;} </style> <!-- , structure made bootstrap --> <div class="container"> <div id="fullbox" class="row-fluid"> <div id="halfbox1" class="span6"> life </div> <div id="halfbox2" class="span6"> good! </div> </div> </div>
this create 2 containers in row equal width and:
1.) style container (fullbox), give background, shadow , border;
if wrap around fullbox container myclass (my styled div), work. in case myclass has 1px border, brake bootstrap layout 2 pixels both horizontally , vertically adding 1px border around.
<div class="container"> <div class="myclass"> <div id="fullbox" class="row-fluid"> <div id="halfbox1" class="span6"> life </div> <div id="halfbox2" class="span6"> good! </div> </div> </div> </div>
in case myclass inside fullbox, not brake bootstrap layout not work either due properties of bootstrap containers. elements inside not stretch myclass around them, output 2px line on top (the borders of 0px high myclass)
<div class="container"> <div id="fullbox" class="row-fluid"> <div class="myclass"> <div id="halfbox1" class="span6"> life </div> <div id="halfbox2" class="span6"> good! </div> </div> </div> </div>
in case myclass additional class of fullbox (class="row-fluid myclass"), work again brake bootstrap layout well, when using border:
<div class="container"> <div id="fullbox" class="row-fluid myclass"> <div id="halfbox1" class="span6"> life </div> <div id="halfbox2" class="span6"> good! </div> </div> </div>
this more complicated when styling halfbox containers, here example used of other 2 examples above wrapping around or using styled div inside halfbox
<div class="container"> <div id="fullbox" class="row-fluid"> <div id="halfbox1" class="span6 myclass"> life </div> <div id="halfbox2" class="span6 myclass"> good! </div> </div> </div>
i sure there must "the right way it" or @ least highly recommended way in order achieve clean , efficiently reusable code. goal keep bootstrap intact , use stylesheet borders , bgcolors, without braking framework's layout.
here working sample: http://jsfiddle.net/yatko/y74u7/
any highly appreciated!
i'm not understanding how 1px border breaking bootstrap layout. i've added css3 stylings , padding , margin layouts in bootstrap fluid layouts , had no problems.
<div class="container"> <div id="fullbox" class="row-fluid"> <div id="halfbox1" class="span6 myclass"> life </div> <div id="halfbox2" class="span6 myclass"> good! </div> </div> </div> <!-- example2 myclass brakes layout --> <div class="container"> <div class="row-fluid"> <div class="span6 myclass"> <p>1<br /> 2<br /> 3<br /></p> </div> <div class="span6 myclass"> 4<br /> 5<br /> 6<br /> </div> </div> </div>
you need combine class on span, or break layout. span class inside of container important. order in way cascade has way otherwise css doesn't work.
Comments
Post a Comment