I am mainly a backend developer but am trying to get a layout to come out right. Basically I am creating a list view page that will contain a div
tag on the left that has a bunch of filters (drop down lists, checkboxes, etc). On the right side of the screen I am going to have a div
tag that contains a grid. This seems to be working but looks terrible when I'm on an overhead or when my screen is not maxed. Am I doing this right? Basically here is what I am after:
The CSS I had done for this was as simple as this:
.filterContainer {
width:20%;
float:left;
}
.gridContainer {
width:79%;
float:right;
}
Basically .filterContainer
is my left div
(dLeft) and .gridContainer
is my right div
(dRight). Is this valid for what I am trying to achieve? The result is as shown here:
http://i.imgur.com/WFasMF1.png
However, if I resize my window I end up with the following result:
http://i.imgur.com/4u9HRlK.png
Which I guess is normal because I'm resizing, but is my css valid?
You can use Frameset for dividing your pages into frames and then add css to it for style.
Maybe you can use
position:absolute
?Or just use
table
tag for what it was designed? It is not like W3C plans to discard that tag in near future.That is not a normal behavoir of floated blocks, since they placed before any normal block and not use normal parent container context.
if you make the left container fixed width that will help. and you can always wrap both those divs in another div where you set a max-width if you'd like.
First of all when you are dealing with Grid Based layouts, always make sure you use
Now, why you need that?
If you see in the diagram below..
CSS adds
margin
,padding
andborder
outside the box and not inside, which is default content box behavior, so when you use the snippet I shared, it changes the box model behavior and makes the element count theborder
andpadding
inside the element.Coming to your issue, the CSS you provided is perfect, but
position
,float
, ormargin
or even uncleared floating elements anything can cause the issue which you are facing, so if you can, consider altering your CSS stylesheet, and would be worth if you usebox-sizing: border-box;
How do you achieve this?
Well, obviously, I won't provide you entire thing, but just a general idea of how to achieve this, as I see you are using
now that's the very strong reason of why I suggested you to alter the box model.width: 79%;
Now here, I have two elements floated to the left, with the box model altered, so I don't have to use
-1%
width
for any of the element. When you need spacing, nest more blocks inside the grid and then, instead ofusemargin
padding
especially on floated parent elements.Demo