Hello,
my question:
How can I set a fix height or width for a div?
Example:
<div id="container">
</div>
CSS:
#container {
?????????
}
If I just enter width: 70% (or height), the div is "growing" with the content. How can I fix the size?
Thank you for helping me.
I think it´s very easy:)
Kind regards
niggoo
CSS: Fix a div?
Started by niggoo, Jun 21 2010 07:20 AM
7 replies to this topic
#1
Posted 21 June 2010 - 07:20 AM
|
|
|
#2
Posted 21 June 2010 - 12:16 PM
Try just "width:100px;" or "height:100px;" instead of "width:100%;", should work... I think, haven't played with CSS for a while. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 27 June 2010 - 03:17 PM
Pixels set a exact width or height where as percentages change depending on browser height/width or screen height/width.
#4
Posted 29 June 2010 - 10:06 PM
With percentages the higher the window is, the higher the div is... but try just to play with it little bit... you could try overflow: hidden; and display: block; ... but that shouldn't affected
#5
Guest_johnny.dacu_*
Posted 07 July 2010 - 08:28 AM
Guest_johnny.dacu_*
for the sake of "art": i belive if you use pt or em you'll have a fixed dimension container too.
#6
Posted 15 July 2010 - 11:45 AM
Include content that matches the width and height of the div. For instance, a bar across the top and another bar along one of the sides, with visibilities set to "invisible". That's the way I do it when it doesn't work.
#7
Posted 15 July 2010 - 11:46 AM
thegamemaker said:
Try just "width:100px;" or "height:100px;" instead of "width:100%;", should work... I think, haven't played with CSS for a while. :)
I have found this doesn't work in a lot of cases. CSS is one of my least favorite computer languages.
#8
Posted 16 July 2010 - 08:28 AM
For a div such as container as I am guessing you are trying to make it the div which will hold the whole page usually only a width is fixed: I tend to use 900px for mine. The height will be based depending on what you have on the current page, which basically means that you can use that div on bot the home page and on the about page. Either way setting a fixed with and height is done through pixels just as thegamemaker said.
I was going to ask you to show me one of those cases until you said CSS is a computer language... I see it more like Paint. But please provide me with some of those examples anyway.
DarkLordofthePenguins said:
I have found this doesn't work in a lot of cases. CSS is one of my least favorite computer languages.


Sign In
Create Account

Back to top









