"Front Siege Lion Road" CSS two column layout--right fixed width, left adaptive

Source: Internet
Author: User

Did a cat factory very classic front-end pen test questions, solved the two columns have been on the understanding of the layout of too few problems.


The title requirement is right aside fixed width 200px, left content adaptive.

Originally directly with float, found aside will always be "squeeze" to content below, footer above position, debug for a long time finally saw Daniel's blog to realize this problem.


The basic idea is :

①content width is not set, let it default auto, set the height (good-looking)

②aisde on the right. Float:right, set fixed width 200px

③ Focus. Set the content of the aside direction (right) on the Maigin, and margin value to be enough to lay down aside

④, is also a deceptive place ... The body represents aside Div refers to the content of the Div front, so that the browser rendering content when it is just "stacked" to the left margin of aside, perfect side-by.


Effect Chart



Implementation Code

(different screen different browser effect, not many browser compatibility, only for reference)

body{margin:0;
Padding:0 5px;
	} #header {width:100%;
	height:18%;
	Border:green 1px solid;
	margin-bottom:1%;
	} #logo {width:80px;
	height:80px;
	border:red 1px solid;
	Float:left;
	margin-top:20px;
margin-left:20px;
	} #username {width:200px;
	height:30px;
	Border:black 1px solid;
	Float:right;
	margin-top:75px;
	margin-right:20px;
Text-align:right;
	} #main {Overflow:hidden;} #content {height:430px;
	Border:blue 1px solid;
margin-right:240px;
	} #aside {width:200px;
	height:30px;
	border:red 1px solid;
Float:right;
	} #footer {width:100%;
	height:9%;
	Border:black 1px solid;
	Clear:both;
margin-top:1%; }
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.