Home > Web Front-end > HTML Tutorial > Pure CSS realizes three-column layout (fixed on both sides, adaptive in the middle)_html/css_WEB-ITnose

Pure CSS realizes three-column layout (fixed on both sides, adaptive in the middle)_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:40:22
Original
1263 people have browsed it

After reading some online cases, I found it to be complicated, so I compiled an article to explain this.

Let me review it myself. Someone asked this question before, but I haven’t answered it yet. ==

Look at the code:

html:

1 <div class="top">this is top</div>2 <div class="container">3     <div class="left">this is left</div>4     <div class="center">this is center</div>5     <div class="right">this is right</div>6 </div>7 <div class="footer">this is footer</div>
Copy after login

Then CSS:

 1 .top{ 2     width: 100%; 3     height: 40px; 4     background-color: #cccccc; 5 } 6 .footer{ 7     width: 100%; 8     height: 50px; 9     background-color: #abdc44;10 }11 /*左右固定,中间自适应*/12 /*Start*/13 .container{14     width: 100%;15     height: 100%;16     position: relative;17 }18 .left{19     position: absolute;20     left: 0;21     top: 0;22     width: 400px;23     height: 800px;24     background-color: black;25 }26 .center{27     width: auto;    /*如果没有这一句,那么,center这个div的文字就不会自动换行*/28     margin: 0 400px;29     height: 1000px;30     background-color: yellow;31 }32 .right{33     position: absolute;34     top: 0;35     right: 0;36     width: 400px;37     height: 900px;38     background-color: red;39 }40 /*End*/    
Copy after login

The end looks like this:

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template