thibo1025 Posted September 14, 2006 Share Posted September 14, 2006 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 More sharing options...
boen_robot Posted September 14, 2006 Share Posted September 14, 2006 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 More sharing options...
Cronthenoob Posted September 14, 2006 Share Posted September 14, 2006 Try adding another div around both of your divs and giving it a fixed width. <div style="width:800px"> <div>Something</div> <div>Something else</div></div> Link to comment Share on other sites More sharing options...
thibo1025 Posted September 15, 2006 Author Share Posted September 15, 2006 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 More sharing options...
holmedwa04 Posted September 15, 2006 Share Posted September 15, 2006 Just change it to percentages then, instead of 800, use 50% or whatever. Link to comment Share on other sites More sharing options...
Err Posted September 16, 2006 Share Posted September 16, 2006 It would work best if you changed the float: right; to float: left;. Link to comment Share on other sites More sharing options...
thibo1025 Posted September 17, 2006 Author Share Posted September 17, 2006 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 More sharing options...
Err Posted September 17, 2006 Share Posted September 17, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now