Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the height of a <div> element?

Tags:

html

css

I've defined my div's height in a stylesheet:

.topbar{   width:100%;   height:70px;   background-color:#475; } 

But as soon as text is entered into the div, the divs height changes.

Any ideas?

like image 811
Jake Avatar asked Dec 04 '10 17:12

Jake


People also ask

How do you fix height issues in CSS?

Absolute positioning removes the content div (and everything else) from the flow of the page. That makes it so the containers don't know the size of the inner elements. Remove all the . abs classes from everything inside the container, and the white background will correctly stretch as you want.

How do I keep my DIVs the same height?

The two or more different div of same height can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. The used display property are listed below: display:table; This property is used for elements (div) which behaves like table.

Can div have height?

This seems like the ideal candidate for transition from a table-based layout to a CSS layout. It makes sense: both DIVs and tables can be nested, have HEIGHT and WIDTH attributes set, contain borders, etc.


1 Answers

change the div to display block

.topbar{     display:block;     width:100%;     height:70px;     background-color:#475;     overflow:scroll;     } 

i made a jsfiddle example here please check

http://jsfiddle.net/TgPRM/

like image 113
kobe Avatar answered Oct 02 '22 06:10

kobe