Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
天小編為大家介紹五種css樣式布局以及內服源代碼作為介紹,采用的方式是行內級樣式(就是將css樣式代碼與html寫在一起)
已知布局元素的高度,寫出三欄布局,要求左欄、右欄寬度各為300px,中間自適應。
一、浮動布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>浮動布局</title>
<style type="text/css">
.wrap1 div{
min-height: 200px;
}
.wrap1 .left{
float: left;
width: 300px;
background: red;
}
.wrap1 .right{
float: right;
width: 300px;
background: blue;
}
.wrap1 .center{
background: pink;
}
</style>
</head>
<body>
<div class="wrap1">
<div class="left"></div>
<div class="right"></div>
<div class="center">
浮動布局
</div>
</div>
</body>
</html>
浮動布局的兼容性比較好,但是浮動帶來的影響比較多,頁面寬度不夠的時候會影響布局。
二、絕對定位布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>絕對定位布局</title>
<style type="text/css">
.wrap2 div{
position: absolute;
min-height: 200px;
}
.wrap2 .left{
left: 0;
width: 300px;
background: red;
}
.wrap2 .right{
right: 0;
width: 300px;
background: blue;
}
.wrap2 .center{
left: 300px;
right: 300px;
background: pink;
}
</style>
</head>
<body>
<div class="wrap2 wrap">
<div class="left"></div>
<div class="center">
絕對定位布局
</div>
<div class="right"></div>
</div>
</body>
</html>
絕對定位布局快捷,但是有效性比較差,因為脫離了文檔流。
三、flex布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>flex布局</title>
<style type="text/css">
.wrap3{
display: flex;
min-height: 200px;
}
.wrap3 .left{
flex-basis: 300px;
background: red;
}
.wrap3 .right{
flex-basis: 300px;
background: blue;
}
.wrap3 .center{
flex: 1;
background: pink;
}
</style>
</head>
<body>
<div class="wrap3 wrap">
<div class="left"></div>
<div class="center">
flex布局
</div>
<div class="right"></div>
</div>
</body>
</html>
自適應好,高度能夠自動撐開
四、table-cell表格布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>table-cell表格布局</title>
<style type="text/css">
.wrap4{
display: table;
width: 100%;
height: 200px;
}
.wrap4>div{
display: table-cell;
}
.wrap4 .left{
width: 300px;
background: red;
}
.wrap4 .right{
width: 300px;
background: blue;
}
.wrap4 .center{
background: pink;
}
</style>
</head>
<body>
<div class="wrap4 wrap">
<div class="left"></div>
<div class="center">
表格布局
</div>
<div class="right"></div>
</div>
</body>
</html>
兼容性好,但是有時候不能固定高度,因為會被內容撐高。
五、網格布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>網格布局</title>
<style type="text/css">
.wrap5{
display: grid;
width: 100%;
grid-template-rows: 200px;
grid-template-columns: 300px auto 300px;
}
.wrap5 .left{
background: red;
}
.wrap5 .right{
background: blue;
}
.wrap5 .center{
background: pink;
}
</style>
</head>
<body>
<div class="wrap5 wrap">
<div class="left"></div>
<div class="center">
網格布局
</div>
<div class="right"></div>
</div>
</body>
</html>
希望大家可以一直關注我,支持我!感謝!!!
導航欄
圖書管理功能模塊圖
圖書管理功能包4括大模塊 ,16個子模塊。
1. 制作方式: 列表<ul><li>制作。
四大模塊:用一個<ul><li></li></ul>列表制作出來,每個模塊下面的四個子模塊用同樣的<ul><li></li></ul>列表嵌套出來。
具體格式如下:
<ul> <li>模塊1 <ul> <li>模塊1.1</li> <li>模塊1.2</li> <li>模塊1.3</li> <li>模塊1.4</li> </ul> </li> <li>模塊2 <ul> <li>模塊2.1</li> <li>模塊2.2</li> <li>模塊2.3</li> <li>模塊2.4</li> </ul> </li> .......... </ul>
2.導航標簽<a>:都是一個超鏈接,通過點擊鏈接到相應的導航頁面。
所以在每個列表選項中,都應該加入超鏈接<a>標簽。
<ul> <li><a href="javascript:;" >用戶管理</a></li> ... </ul>
3.導航框的修飾:CSS樣式表
3.1 樣式表接入方式:
一般用鏈接式<link >,運用高內聚,低耦合的思想。
<link rel="stylesheet" type="text/css" href="CSS/demo.css">
3.2標簽選擇器
行內選擇器>id選擇器>class選擇器>標簽選擇器
常用到的為 id選擇器、class選擇器、標簽選擇器。
例如:
<ul> <li class="litems"><a href="javascript:;">用戶管理</a> <ul class="uitems"> <li><a href="javascript:;">添加用戶</a></li> </ul> </li> </ul>
具體用法見:HTML/CSS中可直接輸數據的表格
4.導航欄的框框
模塊標簽特點:
litems類標簽 中 <a>標簽的樣式如下:
.litems>a { background-color:#990020; /*背景色*/ height:30px; display:block; /*塊顯示*/ line-height:30px; /*垂直居中*/ border-left: solid 12px #711515; /*邊框*/ padding-left:5px; /*左邊距*/ }
5.鼠標懸浮變化--- a:hover 屬性
鼠標未懸浮狀態
鼠標懸浮狀態
特點:鼠標懸浮時,字體變為黃色。
a:hover { color:#FF0; }
制作一個簡單的導航欄,常用的就是列表格式。通過列表的嵌套和樣式的修改,即可建立一個簡約得體的導航列表。
以下附帶部分樣式源碼:
HTML列表內容
CSS樣式表源碼:
下是一些常用的HTML網頁源代碼示例,這些示例可用作HTML文檔的基礎:
1、創建一個簡單的HTML文檔結構:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"content="width=device-width,initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<h1>Hello,World!</h1>
<p>This is a simple HTML webpage.</p>
</body>
</html>
2、插入圖片:
<img src="image.jpg"alt="Description of the image">
3、創建超鏈接:
<a href="https://www.example.com">Visit Example.com</a>
4、創建無序列表:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
5、創建有序列表:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
6、創建表格:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1,Cell 1</td>
<td>Row 1,Cell 2</td>
</tr>
<tr>
<td>Row 2,Cell 1</td>
<td>Row 2,Cell 2</td>
</tr>
</table>
7、插入段落:
<p>This is a paragraph of text.</p>
8、插入換行符:
<p>This is some text.<br>This is on a new line.</p>
9、創建一個文本輸入框:
<input type="text"name="username"placeholder="Enter your username">
10、插入按鈕:
<button type="button">Click me</button>
這些示例代碼只是HTML的基礎,HTML具有更豐富的功能和標記選項,可以根據需要進行擴展和定制。請根據您的具體需求,使用這些示例作為起點,構建您自己的網頁。
【名揚銀河企業網站系統】
【免費】提供企業【網站源碼】,簡單易用,無須擁有代碼基礎。
歡迎留言或私信我們咨詢。
以上內容由【名揚銀河】企業網站系統原創發布,轉載請注明出處。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。