Home >Web Front-end >HTML Tutorial >【】Place two DIVs side by side in one DIV. The size of the div on the right is variable. _html/css_WEB-ITnose

【】Place two DIVs side by side in one DIV. The size of the div on the right is variable. _html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 12:02:262341browse


As shown in the picture:
I want to make a web page, in which the head is a div, with an image on the left and a background color on the right (the same color as the right side of the image). According to the browser The size of repeat-x.
Below is a #middle div nested with two divs called left and right, where the width of left is 200px; the right edge of right should be consistent with the right edge of the head.

The problem is that the right one is always narrower and cannot be adapted to the page size? ? ?


Reply to discussion (solution)

Add a div to the right div and add an inner class

div1{float:left;position:relative;margin-right:-200px;}div2{float:right;width:100%;}div2 .inner{margin-left:200px;}

http://jsfiddle.net/jikeytang/b75z9/2/
If the Internet speed is fast, open it and take a look.

Go back to 2L and add margin-right:-200px; then the left side disappears

"The problem is that the right side is always narrower and cannot be adjusted according to the page size. Adapt? ? "What does it mean?
If the left width is fixed, the right side should fill the remaining width of the common container and adapt according to the page width. When the page width is small, the right side will be very narrow. If you want the right div not to be too narrow when the page width is small, you can define a min-width for the right div, or use media query for responsive layout to display the right or left div vertically, not in one line.
Here is an example of a simple two-column layout:




-8" />

Test title> <br> <br> <br>






Look at your width design Whether the size is equal on the left and right and the height

You can also use DWcs5 to insert a table with 2 rows and 2 columns

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn