標籤:images color after title highlight 引用 輸入 ted har
前言:
主要概要:
1、HTML+CSS補充
2、DOM事件
3、jQuery樣本
內容概要:
1、布局
代碼如下
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> body{ margin:0; } .w{ width:980px; margin:0 auto; border:1px solid greenyellow; } </style></head><body> <div style="background-color: black;color: white;"> <div class="w">標題</div> </div> <div> <div class="w">內容</div> </div></body></html>View Code
效果如下:
2、clear both的另外一種寫法 (清除浮動)
常規寫法就是如下所示:
<body> <div style="background-color: greenyellow;"> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="width: 200px;height: 200px;border: 1px solid red;float: left;"></div> <div style="clear: both;"></div> </div></body>
接著,我們換另外一種寫法
注意:有content才會加標籤,一般都是這麼寫,不能寫display: none
<style> .clearfix:after{ content: ‘.‘; display: block; clear: both; visibility: hidden; height:0; } </style>
所有網站這個都會用到。
以後就寫一個公用的CSS,放在引用即可,after是指在這個標籤內容的後面
<link rel="stylesheet" href="commons.css">
3、頁面配置,拖動瀏覽器如何讓格式不變
第一種方法:
在外面定義一個div給一個固定寬度,如果縮小他會自動出現捲軸。如
寫法如下:
<div style="width: 800px;">
輸入標籤
</div>
方法2:@media
<style> @media (min-width: 800px){ .item{ width:20%; float: left; } } @media (max-width: 700px){ .item{ width:50%; float: left; } } </style>
一個初學者的辛酸路程-jQuery