| | |
CSS questions
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 35
Reputation:
Solved Threads: 0
Hello guys, how are you doing?
I have a couple of questions please, I would appreciate any help.
1- I have three "relative <div>" I want to put them next to each other and making sure if someone has less resolution, there wont be a scroll bar. But instead the <div> will adjust and the text will go below.
I made sure all three have the following attributes:
position: relative;
float: left;
But the problem is that each one of these div's has a width according to the text in it, which means they are next to each other. I also added a <div> to wrap all three <div> it didnt work.
I tried giving them a width of 33% each and one 34% but one of them jumps down whenever I resize my browser.
here is my code:
I tried making the height the same, but it didnt work either.
2- How can I center a table or an image in a <div>?
Thanks in advance
I have a couple of questions please, I would appreciate any help.
1- I have three "relative <div>" I want to put them next to each other and making sure if someone has less resolution, there wont be a scroll bar. But instead the <div> will adjust and the text will go below.
I made sure all three have the following attributes:
position: relative;
float: left;
But the problem is that each one of these div's has a width according to the text in it, which means they are next to each other. I also added a <div> to wrap all three <div> it didnt work.
I tried giving them a width of 33% each and one 34% but one of them jumps down whenever I resize my browser.
here is my code:
HTML and CSS Syntax (Toggle Plain Text)
.bassano1 { width: 33%; } .bassano2 { width: 33%; } .bassano3 { width: 33%; } .bassano1, .bassano2, .bassano3, .bassano4, .bassano5 { position: relative; background-color: #008001; border: 2px solid #095E09; float: left; height: 50 %; }
2- How can I center a table or an image in a <div>?
Thanks in advance
•
•
Join Date: Jan 2008
Posts: 141
Reputation:
Solved Threads: 19
Hey,
I notice that you apply 2px borders to the divs. With the box model, borders are added to the width of the container.
You therefore have 99% width across the three divs, + 12px for the borders (left and right).
I'd suggest making the widths something lower, e.g. 32% + a border.
And to centre an image within a div, I believe if you use text-align: center on the div, it should centre the image itself.
R.
I notice that you apply 2px borders to the divs. With the box model, borders are added to the width of the container.
You therefore have 99% width across the three divs, + 12px for the borders (left and right).
I'd suggest making the widths something lower, e.g. 32% + a border.
And to centre an image within a div, I believe if you use text-align: center on the div, it should centre the image itself.
R.
•
•
Join Date: Oct 2008
Posts: 35
Reputation:
Solved Threads: 0
thanks for the reply ...
as for the images i tried using center align but it didnt work for the img .. i use center align for img in css and not for the whole div since it contains soms text.
and i will do what u told me but there is a problem of div jumping down if i dont use the width and put some value into it.
any idea's ?
as for the images i tried using center align but it didnt work for the img .. i use center align for img in css and not for the whole div since it contains soms text.
and i will do what u told me but there is a problem of div jumping down if i dont use the width and put some value into it.
any idea's ?
css Syntax (Toggle Plain Text)
.bassano1 { width: 33%; } .bassano2 { width: 33%; } .bassano3 { width: 33%; } .bassano1, .bassano2, .bassano3, .bassano4, .bassano5 { position: relative; background-color: #008001; border: 2px solid #095E09; float: left; height: 50 %; }
height: 50%; and retry, Last edited by almostbob; Feb 8th, 2009 at 4:47 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Oct 2008
Posts: 76
Reputation:
Solved Threads: 6
The problem seems to be your borders, without the borders everything was ok, but the borders didn't fit on the screen, when I set the divs to 32%, it went back.
About the text you complained wouldn't stay in the div, is it in a <P> or is it straight in the div? (it should be in a p) .
Concerning that p, did you set a font size for it?
To center objects, you can try using:
But, that will only work if you set a height for the centered object, for example:
About the text you complained wouldn't stay in the div, is it in a <P> or is it straight in the div? (it should be in a p) .
Concerning that p, did you set a font size for it?
To center objects, you can try using:
margin: 0 auto; But, that will only work if you set a height for the centered object, for example:
height: 100% If I have been helpful add to my reputation!
•
•
Join Date: Oct 2008
Posts: 35
Reputation:
Solved Threads: 0
Thanks for the reply
1- The text is indeed in a <p>, I did not set a font-size I just made the position relative. But the body has a font-size of 12px.
2- I tried centering using the margin but it didnt work.
3- I am also trying to make the heights of each div the same
but I dont seem to succeed in it. But the main problem is the divs for now. I have always used absolute positioning and relative positioning isnt my thing.
1- The text is indeed in a <p>, I did not set a font-size I just made the position relative. But the body has a font-size of 12px.
2- I tried centering using the margin but it didnt work.
3- I am also trying to make the heights of each div the same
but I dont seem to succeed in it. But the main problem is the divs for now. I have always used absolute positioning and relative positioning isnt my thing.
Several points:
Height can't see the browser window size in most browsers.
Most browsers correctly put the surrounding styles (margin, border, padding) OUTSIDE the size styles (width, height). Internet Explorer crams them INSIDE instead. The cure for this is to not use nonzero surrounding styles with size styles in the same style or tag.
Center text reliably using the following code:
In the stylesheet, place:
Then, where you want to place the centered text, put this code:
The p tag may be replaced by one of the h tags.
Center images reliably using the following code:
In the stylesheet, place:
Then, where you want to place the centered image, put this code:
There must be room for the image, or it won't work.
Center other objects reliably using the following code:
In the stylesheet, place:
Then, where you want to place the centered object, put this code:
Put the name of the tag for the object you have instead of the word "tag".
Height can't see the browser window size in most browsers.
Most browsers correctly put the surrounding styles (margin, border, padding) OUTSIDE the size styles (width, height). Internet Explorer crams them INSIDE instead. The cure for this is to not use nonzero surrounding styles with size styles in the same style or tag.
Center text reliably using the following code:
In the stylesheet, place:
HTML and CSS Syntax (Toggle Plain Text)
.cenx {text-align: center;}
HTML and CSS Syntax (Toggle Plain Text)
<p class="bxfix cenx">Your Text to be Centered</p>
Center images reliably using the following code:
In the stylesheet, place:
HTML and CSS Syntax (Toggle Plain Text)
.cenx {text-align: center;} .ceni {clear: both;} .bxfix {margin: 0; border: none; padding: 0;}
HTML and CSS Syntax (Toggle Plain Text)
<div class="bxfix cenx"> <img src="yourimag.jpg" alt="description" class="ceni" /> </div>
Center other objects reliably using the following code:
In the stylesheet, place:
HTML and CSS Syntax (Toggle Plain Text)
.cenx {text-align: center;} .ceni {clear: both;} .bxcen {margin-left: auto; margin-right: auto; border: none; padding: 0;}
HTML and CSS Syntax (Toggle Plain Text)
<div class="bxcen cenx"> <tag>Your object</tag> </div>
Daylight-saving time uses more gasoline
Divs next to each other never have the same height. They each expand downward just enough to hold their contents.
One way to force the height issue is to use the display style on div:
One way to force the height issue is to use the display style on div:
HTML and CSS Syntax (Toggle Plain Text)
div {display: table-cell;}
Daylight-saving time uses more gasoline
![]() |
Similar Threads
- Totally new to html, css questions (HTML and CSS)
- Couple of CSS questions (HTML and CSS)
- CSS and SEO and other beginner questions (Search Engine Optimization)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Meaningless pat on the back, but... (Geeks' Lounge)
Other Threads in the HTML and CSS Forum
- Previous Thread: <h> tag problem
- Next Thread: Issues In IE
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7






