html - How to achieve no outside margins for floats in a div -
I'm learning HTML / CSS basics and I'm stuck in the following problem.
I want to decide 3-size flight sizes in a div outside a fixed-width, and I want to margin between them, not between them.
My problem is that I do not know how to get it. I tried to read about margin-down and negative margins but it is very difficult to understand.
I have put my example on the following JSFDL:
HTML
& lt; Div class = "external" & gt; & Lt; Div class = "article" & gt; & Lt; H2 & gt; Header & lt; / H2 & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 1 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 2 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 3 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 4 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 5 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "article" & gt; & Lt; P & gt; 6 & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
css
.ter {width: 940px; Margin: 0 auto; }. Article {Height: 1500px; Background color: # fcdda1; } .write {width: 300px; Height: 350px; Swim left; Background color: # 4ecac3; Margin: 0-20px 20px 0; }
Can you please tell me:
- What is the recommended way to solve my problem and fix the above example?
- Maybe some early friendly articles / books from which I can learn about it?
Thank you very much, and sorry to ask a start question at the beginning.
Based on CSS 2, a completely cross-browser
here
1) Solution for an original CSS knowledge
is the solution of internal margins only, and is not applicable to the last right, click here.
You have to create a mask to overflow plus margin:
.ter {width: 940px; Hidden flurry; / * Behaves like a mask * Article [width: 960px; / * Set the actual width: 320 * 3 * /}
Advanced solution
Based on CSS 3, only the modern browser (of course, except IE)
CSS nth-child
solution here in this example:
.articles> : Nth-child (3n + 1) {margin correct: 0; }
You can find out how it works.
Since Css3 in IE is an example of incoming parameters, you can use the CSS for specific legacy versions of InternetExplorer (e.g.,
Finally, CSS Based on pseudonym and jQuery.
3) Online resources to practice on CSS
Here you can learn a lot about CSS:
Comments
Post a Comment