All times are UTC - 6 hours




Post new topic Reply to topic   Page 1 of 1
 [ 2 posts ] 
Author Message

 Post subject: Help me with Clearfix css
PostPosted: January 27th, 2015, 7:30 am 
Wizard
Wizard
User avatar

Joined: April 24th, 2007, 9:34 pm
Posts: 386
Gender: Male
Status: Offline
Hey there im currently learning CSS programming and im studying some codes on free web templates to understand programming better, came across these few lines which I need help explaining its purpose and what each line of code does

.clearfix {
width: 960px;
margin: 0 auto;
}
.clearfix:after {
clear:both;
content:"";
display:block;
line-height:0;
height:1%;
visibility:hidden;
}

The first line margin: 0 auto;
Question: Why do you need to specify the margin since its 0 and auto, why not leave it blank since its 0

The second line need help to explain what it all does

__________________
Image Image


Top
 Profile
 

 Post subject: Re: Help me with Clearfix css
PostPosted: January 27th, 2015, 9:40 am 
Level 0
Village Elder
Village Elder
User avatar

Joined: May 13th, 2004, 6:41 pm
Posts: 18,969
Location: The Tower of Mist
Status: Offline

Donor: Wizard (2013)
Friend of Hiker
Lessee here...well, first off, anything with a dot after it is actually a class, not something built into CSS. If you're taking it from this result that I found on Google, notice how the div says class="clearfix" on it. In this case, clearfix is just the name of a hack someone's made, but you could call it anything as long as the page elements you make have the same class name.

As for the first margin line, this link might help. Pages have a top, right, bottom, AND left margin, but if you're going for any type of symmetry at all, usually you don't want them all to be different. In this case, the first number (0) is the top AND the bottom margin, while the second value (auto) is the left and the right margin. That's probably so that your content all starts right at the top (0 top margin) but by putting an automatic margin on both sides, it will also stay in the middle of the page no matter how wide your screen is.

As for your second question, I'm not certain exactly what you're referring to (and since it's a clearfix thing, it's someone's personal hack rather than an official CSS thing) but you can Google "CSS clear" or "CSS content", etc. to get some pretty good pages that explain what each keyword does. The first result is usually W3Schools, and they have a "Try it yourself" button that shows you how each particular tag works.

Best of luck with your programming! :D

__________________
Image

.
Image

.
Legendary themed months are back! Maybe.
Image
!!!!!!!!!!!!!!!!!!!!!!!!


Top
 Profile WWW 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
The Village and this web site are © 2002-2012

ThePub 2.0 - Designed by Goten & Jackstick. Coded by Glodenox & Henner.
With many thanks to the Website Team!