variable-width

Fixed width div on left, fill remaining width div on right

a 夏天 提交于 2020-01-22 05:10:51
问题 I want a div with a fixed width image on the left and a variable width div with a background color, which should extend its width 100% on my device. I can't stop the second div from overflowing my fixed div. When I add overflow:hidden at the variable width div it just jumps under the photo, on the next row. How can I fix this the right way (i.e. without hacks or margin-left, since I need to make the site responsive later with media queries and I have to change the image with other resolution

Prevent float wrap until elements have reached min-width

≯℡__Kan透↙ 提交于 2020-01-03 17:29:35
问题 I have variable-width HTML layout with a fixed-width menu to the left of a content <div> of variable width (set by css max-width and min-width). For very narrow browser windows I would like the content to wrap beneath the menu, and I am currently achieving this by setting float:left on both menu and content. <html> <head> <title></title> </head> <body> <div style="width: 200px; float: left; border: 1px black solid">Menu (200px wide)</div> <div style="max-width: 800px; min-width: 300px; float

How to horizontally center a floating element of a variable width?

六眼飞鱼酱① 提交于 2019-11-27 10:33:29
How to horizontally center a floating element of a variable width? Edit: I already have this working using a containing div for the floating element and specifying a width for the container (then use margin: 0 auto; for the container). I just wanted to know whether it can be done without using a containing element or at least without having to specify a width for the containing element. Assuming the element which is floated and will be centered is a div with an id="content" ... <body> <div id="wrap"> <div id="content"> This will be centered </div> </div> </body> And apply the following CSS:

How to horizontally center a floating element of a variable width?

微笑、不失礼 提交于 2019-11-26 15:17:35
问题 How to horizontally center a floating element of a variable width? Edit: I already have this working using a containing div for the floating element and specifying a width for the container (then use margin: 0 auto; for the container). I just wanted to know whether it can be done without using a containing element or at least without having to specify a width for the containing element. 回答1: Assuming the element which is floated and will be centered is a div with an id="content" ... <body>