I have a situation where I am using a fluid grid that I have built myself. These are parents of two content types I am dealing with: .media-tile and .blurb-tile.
I have removed excess markup that isn't relevant to this question, but my markup essentially looks like this:
<div class="row">
<div class="three columns">
<div class="media-tile">
<!-- content -->
</div><!-- END .media-tile -->
</div><!-- END .three.columns -->
</div><!-- END .row -->
<div class="row">
<div class="twelve columns">
<div class="blurb-tile">
<!-- content -->
</div><!-- END .blurb-tile -->
</div><!-- END .twelve.columns -->
</div><!-- END .row -->
My issue is that I have to have specific styling on the .blurb-tile content block when it follows .media-tilecontent block (as sometimes it doesn't follow it).
I thought that the following traversal method coupled with an adjacent selector would work:
.row .three.columns .media-tile + .row .twelve.columns .blurb-tile {
/* my properties here */
}
However it does not...
In this specific situation, is there a selector that I can use along with traversal in order to create a conditional class for when my .blurb-tile content block follows my .media-tile content block?
Any help on this would be hugely appreciated.
Thank you in advance.
With your current DOM structure isn't possible with pure css(at least with my css knowledge). I provide a jquery solution for your needs:
$(".media-tile")
.parents(".row") //get ancestors elements with class row
.next() //get next element(similar to css adjustment selector)
.find(".blurb-tile") //find element with class blurb-tile
.css("color", "red");//apply css for test purposes
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="three columns">
<div class="media-tile">
</div>
</div>
</div>
<div class="row">
<div class="twelve columns">
<div class="blurb-tile">
this
</div>
</div>
</div>
Also I fix some of your html errors.
References
.parents()
.next()
.find()
Related
I have two forms on a page. Both I would like in the left column in a two-column layout, but the second form has input fields stretching onto the second column.
I could of course create two separate "rows". However, the design calls for the top position of the columns to be at the same height, like columns in a two-column layout typically display.
I don't believe this is necessarily related to Bootstrap because this might be solved with other methods, but I was wondering if Bootstrap had a quick solution for this
This following approach is obviously incorrect syntax and moves the form element in and out of flow, but this is basically what I'd like to accomplish:
<div class="container">
<div class="row">
<div class="col-md-6">
<form id="form1">
</form>
...
<form id="form2">
<!-- ... #form2 inputs ... -->
</div>
<div class="col-md-6">
<!-- ... #form2 inputs cont'd ... -->
</form> <!-- end of #form2 -->
</div>
</div>
</div>
I can already separate the forms on two separate rows, but of course, the right column is lower than the left column.
<div class="container">
<div class="row">
<div class="col-md-6">
<form id="form1">
</form>
</div>
</div> <!-- end of row -->
<div class="row">
<form id="form2">
<div class="col-md-6">
<!-- ... #form2 inputs ... -->
</div>
<div class="col-md-6">
<!-- ... #form2 inputs cont'd ... -->
</div>
</form> <!-- // end of #form2 -->
</div>
</div>
Is there any trick to "collapsing" the space above the right column if this is how the html should be structured, or is there a Bootstrap approach that I'm missing? Open to non-bootstrap methods if necessary.
Have you considered using just one form element to wrap the whole lot, and then separating the two forms using their name attributes? For example:
value="form1[field_name]"
value="form2[field_name]"
When using bootstrap's grid, what is the best way to markup a single full-width column in a row?
Do you have to use container and row to hold the column (.container > .row > .col-xs-12 > .actual-content), or can you get rid of the row and column altogether and simply use a wrapping container (.container > .actual-content)?
Let's say
<div class="container">
<div class="row">
<!-- multiple columns -->
</div>
<div class="row">
<div class="col-xs-12">
<p>Actual content goes here. It will span the entire width.</p>
</div>
</div>
<div class="row">
<!-- multiple columns -->
</div>
</div>
vs
<div class="container">
<div class="row">
<!-- multiple columns -->
</div>
<p>Actual content goes here. It will span the full width.</p>
<div class="row">
<!-- multiple columns -->
</div>
</div>
Is one approach considered superior over the other? Since the column spans the entire width for all media sizes, I don't need any responsive features. Rendered output should be the same, but maybe there are subtle differences which I'm not aware of. Using container, row, and column seems like overkill …
The one without the row/grid according to Bootstrap's own documentation. It is the correct way -- don't wrap it with more classes, that's more markup for NO reason.
I posted about this a couple days ago: col-*-12 (col-xs / col-sm / etc) use in Bootstrap 3
Documentation:
No grid classes are necessary for full-width elements.
This is the correct way:
<div class="container">
<div class="row">
<!-- multiple columns -->
</div><!-- closing .row -->
<p>Actual content goes here. It will span the full width.</p>
<div class="row">
<!-- multiple columns -->
</div><!-- closing .row -->
</div><!-- closing .container -->
Hi, sometimes learning something makes you more confused, I am in that position right now, thanks in advance.
I asked a question in this address: Why <div class="clear"></div> used?
After getting the answer and accepting (I also read the links given in comments section), now I've 2nd and 3rd questions.
According to the input codes given in related question,
Why grid demo code below didn't use <div class="clear"></div>? Again there exist 2 sets of two floating div elements so isn't it suitable to use <div class="clear"></div> just after the last floating div elements?
I explicitly mention that I would expect <div class="clear"></div> code in 2 places: Just after <div class="col col_7"> and just after <div class="col col_4">
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
The owner of accepted answer wrote that: "Without this the content following your nav element may appear alongside your nav element rather than below it." Since he used MAY grammar & I deleted <div class="clear"></div> and saw that nothing has changed in output for IE9 and Chrome 25.0.1364.172; what maked him to write MAY? Old browsers (especially old IE versions)?
This depends on your CSS that is associated with the different classes/ids/elements in your HTML.
<div class="clear"></div> ALWAYS has some css associated with it, that is:
.clear { clear: both; }
The above CSS is what makes it prevent that floating issue. That said... Using a "clear div" as you have shown above is one of many ways to do this.
In your particular case, given this HTML:
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
It is very likely that the class of "row" has the clear: both; property in CSS. That would explain why when you remove the clear div, it stayed the same. Essentially you didn't need the clear div, because the row class already has the CSS attached to it to prevent that issue from happening.
The selector probably looks like this: .row { clear: both; } The .row class probably has other CSS associated with it as well, another very likely property is overflow: hidden; That property can also effect how your divs and surrounding divs interact/behave next to each other.
To summarize: It is NOT the HTML <div class="clear"></div> that prevents this floating issue from happening. It IS the CSS property and value clear: both; which can be applied to any HTML element that prevents the issue from occurring.
Some resources:
CSS Wiki on Overflow property
CSS Wiki on Clear property
Hopefully this clears that up for you? (pardon the pun haha)
I know the very basics of CSS and recently went on with using CSS frameworks because it made my life much easier. I have a question in terms of grid systems, am currently using zurb foundation 3 (http://foundation.zurb.com/)
The problem am facing is mostly when creating a row i cannot give it a specific height. It seems to me like grid systems are designed to use as it is, I read in different places that it is not recommended to try and change the height of a row and to just place items inside it as it is.
In my project, I have a content area whereby I want to display a fixed height and width div but its not working for me. so, can any one advise me what should i do? below is my html code
update: edited the html
<div class="row">
<div class="six columns">
<div style="height:6em; width:5em;>
<!-- my block -->
</div>
</div>
<div class="six columns">
<div style="height:6em; width:5em;>
<!-- my block -->
</div>
</div>
</div>
Your 'style' declarations are wrong
style="height=6em; width:5em;
should be
style="height:6em; width:5em;"
NOTE: you used = instead of : AND you missed the closing quotation "
And you should not use inline styles - separate to a .css file and target them by class
<html>
<head>
<link rel="stylesheet" type="text/css" href="/foundation3/stylesheets/foundation.css"/>
</head>
<body>
<div class="row">
<div class="six columns">
<div style="height:6em; width:5em;">
<!-- my block -->
</div>
</div>
<div class="six columns">
<div style="height:6em; width:5em;">
<!-- my block -->
</div>
</div>
</div>
</body>
</html>
NOTE: I have not declared a DOCTYPE here - this is barebones. It does work I have tested it in Firefox and Chrome. Just stating it does not work is not helpful OP
Here's what I need. It's fully crossbrowseer (if add some styles)
http://jsfiddle.net/Jkz5f/8/
but it's not good solution, because used constant positions
And this line with floats
http://jsfiddle.net/Jkz5f/5/
but if you add "b" string it's will be crash
Does anyone know fully-crossbrowser solution
without (display:table) and without constant margins for ".b"?
using elements as divs isn't a good idea. Just do this:
<div id="table">
<div class="tr">
<div class="a">a</div>
<div class="b">bbbbbbbbbb</div>
<!-- and so on -->
</div>
</div>
of couse, add all the columns you need. Then float everything to the left and add a clear:both to .a, .b ,.c divs OR do this:
<div id="table">
<div class="tr">
<div class="a">a</div>
<div class="b">bbbbbbbbbb</div>
<!-- and so on -->
<div style="clear:both"></div>
</div><!-- end of row -->
</div>