Jump to content

divs


thibo1025

Recommended Posts

Ok I'm used to the old style of setting pages(with tables) and I am getting to learn how to use the newstyle (using divs and positions).my code is this

<div class="1">Somethings</div><div class="2">Something else</div>

And this page is linked to an outer page of CSS in which the code should look like this.

div.1 { height: 30px; float: left; width:20%;}div.2 { height: 30px; float: right; width: 80%;}

my problem is tha when di this, there is a space between the cells. and I cannot get rid of it could you help me out please.

Link to comment
Share on other sites

Add "margin: 0;".By the way, rename the classes so they start with letters. Standart loving browsers choke at classes starting with numbers. Also, use classes for common things, or should I say "styles that apply to more then one element on a page" and IDs if the style is applicable to only one item in a page. In your case, this would mean:

<div class="a" id="b">Somethings</div><div class="a" id="c">Something else</div>

and a CSS:

.a {height: 30px; margin: 0;}#b {float: left; width:20%;}#c {float: right; width: 80%;}

Link to comment
Share on other sites

There are two problems in your answers first of all , the idea of the "margin: 0;" dosent change anything (my classes 1 and 2 were only for the examples). and the idea of Cronthenoob should work but I would prefer to keep my percentages...

Link to comment
Share on other sites

yes but the problem is that if I do that it wont goall the way on the right. U see what I want to do is to have two divs of 20 an 80 percent each and there should be no space in between them.

Link to comment
Share on other sites

css:

.a, .b {  float: left;  height: 20px;  background-color: blue;}.a {width: 80%;}.b {width: 20%;}

html:

<div class="a">Text Here</div><div class="b">Text Here</div>

That code works. I put a background on the divs just to show you there is not gap. Try it out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...