search
HomeWeb Front-endHTML Tutorial多列样式布局_html/css_WEB-ITnose

效果图如下:

代码如下:

  1 <!DOCTYPE html>  2 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  3     <meta charset="UTF-8">  4     <title>Document</title>  5     <style>  6         * {  7             margin: 0;  8             padding: 0;  9         } 10         h2 { 11             margin: 20px 0; 12         } 13         .left1 { 14             width: 200px; 15             height: 100px; 16             green; 17         } 18         .right1 { 19             width: 60%; 20             height: 100px; 21             red; 22         } 23         .left2 { 24             width: 200px; 25             height: 100px; 26             green; 27             display: inline-block; 28         } 29         .right2 { 30             width: 60%; 31             height: 100px; 32             red; 33             display: inline-block; 34         } 35         .left3 { 36             width: 200px; 37             height: 100px; 38             float: left; 39             green; 40         } 41         .right3 { 42             width: 60%; 43             height: 100px; 44             float: right; 45             red; 46         } 47         .mainL, .sitebarL, .mainR, .sitebarR { 48             height: 200px; 49             /*font: bolder 20px/200px '微软雅黑';*/ 50             color: #fff; 51             text-align: center; 52         } 53         .mainL { 54             width: 100%; 55             float: left; 56         } 57         .mainR { 58             width: 100%; 59             float: right; 60         } 61         .mainL .contentL { 62             height: 100%; 63             margin-right: 200px; 64             red; 65         } 66         .mainR .contentR { 67             height: 100%; 68             margin-left: 200px; 69             red; 70         } 71         .contentLR { 72             height: 100%; 73             margin-left: 200px; 74             margin-right: 200px; 75             red; 76         } 77         .sitebarL { 78             width: 200px; 79             float: left; 80             margin-right: -100%; 81             green; 82         } 83         .sitebarR { 84             width: 200px; 85             float: right; 86             margin-left: -100%; 87             green; 88         } 89         .clear { 90             width: 100%; 91             clear: both; 92             height: 10px; 93         } 94         #left { 95                 float: left; 96                 width: 200px; 97                 height: 100px; 98                 green; 99         }100  101         #contentL {102             height: 100px;103             red;104             margin-left: 200px;/*==等于右边栏宽度==*/105         }106         #right {107             float: right;108             width: 200px;109             height: 100px;110             green;111         }112  113         #contentR {114             height: 100px;115             red;116             margin-right: 200px;/*==等于左边栏宽度==*/117         }118         #contentLR {119             height: 100px;120             red;121             margin: 0 200px;122         }123         .cont {124             overflow: hidden;125         }126     </style>127 </head>128 <body>129     <h2 id="普通文档布局">普通文档布局</h2>130     <div class="left1">Left</div>131     <div class="right1">Right</div>132     <div class="clear"></div>133  134  135     <h2 id="行内布局使用inline-block">行内布局使用inline-block</h2>136     <div class="left2">Left</div>137     <div class="right2">Right</div>138     <div class="clear"></div>139  140  141     <h2 id="浮动布局float">浮动布局float</h2>142     <div class="left3">Left:<br>143         width: 200px;<br>144         height: 100px;<br>145         float: left;<br>146         green;147     </div>148     <div class="right3">Right<br>149         width: 60%;<br>150         height: 100px;<br>151         float: right;<br>152         red;153     </div>154     <div class="clear"></div>155  156  157     <h2 id="浮动布局float-margin正边距与多列布局">浮动布局float+margin正边距与多列布局</h2>158     <h3 id="两列">两列</h3>159     <div id="left">160             Left Sidebar<br>161             float: left;<br>162             width: 200px;<br>163             height: 100px;<br>164             green;<br>165     </div>166     <div id="contentL">167         height: 100px;168             red;169             margin-left: 200px;/*==等于左边栏宽度==*/170         <div id="contentInner">171             Main Content172         </div>173     </div>174     <div class="clear"></div>175     <div id="right">176         Right Sidebar<br>177         float: right;<br>178         width: 200px;<br>179         height: 100px;<br>180         green;181     </div>182     <div id="contentR">183         height: 100px;184             red;185             margin-right: 200px;/*==等于右边栏宽度==*/186         <div id="contentInner">187             Main Content188         </div>189     </div>190     <div class="clear"></div>191     <h3 id="三列">三列</h3>192     <div id="left">193         Left Sidebar<br>194         float: left;<br>195         width: 200px;<br>196         height: 100px;<br>197         green;<br>198     </div>199     <div id="right">200         Right Sidebar<br>201         float: right;<br>202         width: 200px;<br>203         height: 100px;<br>204         green;205     </div>206     <div id="contentLR">207         <div id="contentInner">208             Main Content<br>209             height: 100px;<br>210             red;<br>211             margin: 0 200px;<br>212         </div>213     </div>214  215  216     <h2 id="浮动布局float-margin负边距与多列布局">浮动布局float+margin负边距与多列布局</h2>217     <h3 id="两列">两列</h3>218     <div class="sitebarL">219         <h4 id="左侧定宽-px区块">左侧定宽200px区块</h4>220         <p>width: 200px;221             float: left;222             margin-right: -100%;223             green;224         </p>225     </div>226     <div class="mainR">227         <div class="contentR">228             <h4 id="右侧主体自适应区块">右侧主体自适应区块</h4>229             <p>.mainR:width: 100%;230             float: right;</p>231             <p>.contentR:height: 100%;232             margin-left: 200px;233             red;234             </p>235         </div>236     </div>237     <div class="clear"></div>238     <div class="mainL">239         <div class="contentL">240             <h4 id="左侧主体自适应区块">左侧主体自适应区块</h4>241             <p>.mainL:width: 100%;242             float: left;</p>243             <p>.contentL:height: 100%;244             margin-right: 200px;245             red;</p>246         </div>247     </div>248     <div class="sitebarR">249         <h4 id="右侧定宽-px区块">右侧定宽200px区块</h4><h4 id="p-width-px-float-right-margin-left-green-p">250         <p>width: 200px;251             float: right;252             margin-left: -100%;253             green;254         </p>255     </h4></div>256     <div class="clear"></div>257     <h3 id="三列">三列</h3>258     <div class="sitebarL">259         <h4 id="左侧定宽-px区块">左侧定宽200px区块</h4>260         <p>width: 200px;261             float: left;262             margin-right: -100%;263             green;264         </p>265     </div>266     <div class="mainL">267         <div class="contentLR">268             <h4 id="主体自适应区块">主体自适应区块</h4>269             <p>.mainR:width: 100%;270                 float: left;271             </p>272             <p>.contentLR:height: 100%;273                 margin-left: 200px;274                 margin-right: 200px;275                 red;276             </p>277         </div>278     </div>279     <div class="sitebarR">280         <h4 id="右侧定宽-px区块">右侧定宽200px区块</h4><h4 id="p-width-px-float-right-margin-left-green-p">281         <p>width: 200px;282             float: right;283             margin-left: -100%;284             green;285         </p>286     </h4></div>287     <div class="clear"></div> 288 </body></html>

 

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
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.