But Ive got my self into a bit of div confusion. I thought by setting the widths to 50% that would in affect create two columns underneath spanning top row. Here is the codepen:
Not only am i unable to get the columns to fill just 50% I’m also having trouble with the images having text to the right of them
Go validate your code. You definitely have some invalid CSS there.
Your CSS isn’t even taking effect. For multiple reasons. FYI please come up with better ID / class names. #packages, #packages1, and #packages2 is all very odd naming. Your relationship with them is parent → child / child. Also it’s confusing becuase one is #packages, and the children are #package1/2. Please work on your ID/class naming.
FYI if you want to select an element with an ID and a class, then you have to concentate the selector. You had this:
#packages .fluid{}
Which is trying to select a .fluid child within #packages. When in realiaty they were the same element. You need to do
#packages.fluid{}
There are a lot of issues I saw, but validation is needed first.
I have to run to meeting so I am sorry I cant provide an actual answer in code. But I did notice the following errors:
I think you trying to target tags like: <div id="package" class="fluid"> with the selector: #package .fluid{} , which should be: #package.fluid{} ( no space, otherwise you are actually targeting elements which are descendants of #package with a class of .fluid)
The use os so many ID could be causing some SERIOUS specificity conflicts . Remember CSS targets by select or and order in the stylesheet, not by name space . In other words if you have one wrapper with #ID2 thats inside another wrapper named #ID1 and a target element: . target. If you wrote
Aside from the issues mentioned.
They would also need to be display: inline-block rather than the default block for div’s, for them to appear side by side.
But for that kind of 2 col layout, I would probably go with display: table for a parent container and display: table-cell for the 2 columns. You could also add table-layout: fixed to the parent to keep them even sized.
I have not had time yet to fully fathom what’s going on, but clearly things are a bit weird, with the horizontal scrollers appearing.
But one thing to mention straight off, the suggestion was to use display: table in css, as opposed to an actual
in html. Reasons being, it keeps better semantics, slapped wrist for using html table for layout in 2015, the other reason it will enable you to drop the 2 col layout on small screens by declaring a different display type on a media query.
If there is a tutorial to what you think works best for the layout i’m after please ping me the url. Sounds like a table may not be what you were hinting at, though it is creating the layout shape i want
Looks like half my post got lost!
Was just saying that you would be better with display: table rather than a html <table> for better semantics and so you can drop the 2 col layout on smaller screens by switching to another display type in a query.
Yes, that was just a bare bones example, it will need a bit more like width controls and suchlike to look right, probably table-layout: fixed to make the 2 cols equal.
I goy t my self creating alot of divs and battling with text not lining up next too images. I suppose I am essentially trying to get a 4 column layout, got my self in a real muddle with this one
Yes, it can do. As mentioned, it will need some additional styling to make it look perfect, I was just showing the very basics to get two columns. It effectively turns the containing div to a table and the inner divs to cells. You don’t have to define rows if there is just one. I may try a simple pen if I find time.