June 9, 2018 at 10:04 am #272444
I want to have a top, middle, and bottom division to my page.
I want the middle to contain a left and right division.
The CodePen example is at https://codepen.io/david263/pen/VdPbgP .
The output isn’t in blocks at all. What did I do wrong?June 9, 2018 at 11:28 am #272447
what did I do wrong?
Malformed class attribute syntax in the HTML.
Help here https://www.w3schools.com/tags/att_global_class.asp
Malformed syntax in CSS / property:value pairing mistakes.
Help here https://www.w3schools.com/css/css_syntax.asp
Horizontal borders add to the box-model, pushing out the overall width so that the 2 floats don’t sit side-by-side. Theyll each sit on a new line. This can be fixed by removing the borders, or change 50% to 49% to see effect of the intended layout in action. If you want to keep all the borders, you could look into removing 2 pixels from each side of the floated divs with calc() https://www.w3schools.com/cssref/func_calc.aspJune 9, 2018 at 3:54 pm #272451
Thank you! I fixed the errors, but I’m still not seeing two side-by-side boxes inside the middle box.June 9, 2018 at 11:57 pm #272453
Have you added “LEFT/RIGHT” text now too? I can’t remember seeing that yesterday. Never mind. Remember that text is an inline element, trying to occupy the same line space as the 2 half-width floated elements, so their overall width (text + left float + right float) is going to exceed 100%. In other words, there’s not enough room for everything to sit on one line so something is going to spill onto another line. Take out the text so that it doesn’t interfere with the floats.June 10, 2018 at 12:00 am #272454
p.s. you don’t need to define
display:block;in the CSS. Divs are block-level elements by default.June 10, 2018 at 4:16 am #272457
Your last two answers did not help, because blocks are useless to my design unless they contain text and other elements. I’m sorry I did not make it clear that this is for presentation on the Web as a Web page.
I want a top block, middle block, and bottom block. Inside the middle block I want a left block and a right block, no matter what the viewport size. The design must be liquid and adaptable between tiny cell phone and large desktop.June 10, 2018 at 4:59 am #272458
I have found this good answer on another forum:June 10, 2018 at 6:01 am #272460
Your last two answers did not help
With all due respect, the reason why my answers did not help you is because you don’t understand enough about the tools you’re working with. I would respectfully suggest that you learn more about layout so that you are better placed to decide what is best in a given situation. Here’s a good place to start http://learnlayout.com/
And if you’re going to critique what a good answer is, at least base both cases on the same criteria. The floats work fine with the LEFT/RIGHT text removed https://codepen.io/anon/pen/WyRYzB
And conversely, flex fails with the LEFT/RIGHT text present https://codepen.io/anon/pen/oyBQdo
Please research more about flex, vendor prefixes (you’ll need them), and suitable fallbacks for older browsers, before you decide to use it for a full web page structure because the demo you posted (which is a reduced test case) won’t be compatible for all users as it currently stands. The floats, while limited by the constraints of older tech, are stable in older browsers and more likely to give the same output for the vast majority of users. Both methods have pros and cons so I recommend you do more research before you commit.June 10, 2018 at 9:13 am #272471
Beverly, thanks for your comments. I think they are all appropriate.
Indeed, I got exactly the behavior I wanted by doing more reading about this wonderful new “flex” css element.
I’ve got it fixed now and it works great. I just had to use the right css. Thanks, all.
Of course, I will need some support for older browsers (maybe through the amazing Autoprefixer, or as you say through floats), and perhaps a little better customization for two or three major width “breakpoints” when I go production.
You must be logged in to reply to this topic.