|
導(dǎo)讀網(wǎng)頁的本質(zhì)就是超級文本標(biāo)記語言,通過結(jié)合使用其他的Web技術(shù)(如:腳本語言、公共網(wǎng)關(guān)接口、組件等),可以創(chuàng)造出功能強大的網(wǎng)頁。因而,超級文本標(biāo)記語言是萬維網(wǎng)(Web)編程的基礎(chǔ),也就是說萬維網(wǎng)是建立... 網(wǎng)頁的本質(zhì)就是超級文本標(biāo)記語言,通過結(jié)合使用其他的Web技術(shù)(如:腳本語言、公共網(wǎng)關(guān)接口、組件等),可以創(chuàng)造出功能強大的網(wǎng)頁。因而,超級文本標(biāo)記語言是萬維網(wǎng)(Web)編程的基礎(chǔ),也就是說萬維網(wǎng)是建立在超文本基礎(chǔ)之上的。超級文本標(biāo)記語言之所以稱為超文本標(biāo)記語言,是因為文本中包含了所謂“超級鏈接”點。 在頁面開發(fā)中,常常需要一些小圖形來美化頁面。這些圖形可以用圖片形式展現(xiàn),但頁面每次加載圖片需要花費時間,那么用css如何實現(xiàn)這些圖形?本章就給大家介紹css如何使用利用border和border-radius繪制一些小圖形(代碼實例)。有一定的參考價值,有需要的朋友可以參考一下,希望對你們有所幫助。大都知道border屬性有四個參數(shù),那么border-radius必然也是有四個參數(shù) 我們知道border屬性的四個參數(shù)分別是border-top,border-right,border-bottom,border-left.(按順時針方向) 那么border-radius四個參數(shù)是什么了? border-radius:上左,上右,下右,下左; 下面我們利用border-radius繪制一些大家平時常見的圖片。 1.簡單的圓形 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div{
width: 200px;
height: 200px;
background: red;
border-radius: 50%;
}
</style>
</head>
<body>
<div id="div">
</div>
</body>
</html>效果圖:
2.橢圓 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div{
width: 100px;
height: 200px;
background: red;
border-radius: 50%;
}
</style>
</head>
<body>
<div id="div">
</div>
</body>
</html>效果圖:
3.心型 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div{
position: relative;
width: 200px;
height: 180px;
border: 1px solid black;
}
.left{
position: absolute;
top: 0;
left: 100px;
width: 100px;
height: 170px;
background: red;
/*左下角為旋轉(zhuǎn)基點*/
transform-origin: 0 100%;
transform: rotate(-45deg);
border-radius: 50% 50% 0 0;
/*讓left的上左和上右變成圓形就可以*/
}
.right{
position: absolute;
top: 0;
left: 0px;
width: 100px;
height: 170px;
background: red;
/*右下角為旋轉(zhuǎn)基點*/
transform-origin: 100% 100%;
transform: rotate(45deg);
border-radius: 50% 50% 0 0;
/*讓right的上左和上右變成圓形就可以*/
}
</style>
</head>
<body>
<div id="div">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>效果圖:
4.雞蛋 我們聽說達芬奇畫雞蛋,我在這里用css畫雞蛋 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div{
position: relative;
width: 100px;
height: 180px;
background: red;
border-radius: 50% 50% 50% 50%/60% 60% 40% 40%;
/*border-radius參數(shù)在/左右的區(qū)別,/左邊是四個圓角的水平半徑/右邊是四個圓角垂直半徑*/
}
</style>
</head>
<body>
<div id="div">
</div>
</body>
</html>效果圖:
5.對話框 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div {
width: 120px;
height: 80px;
background: red;
position: relative;
border-radius: 10px;
margin-left: 50px;
}
#div:before {
content:"";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid red;
border-bottom: 13px solid transparent;
}
</style>
</head>
<body>
<div id="div">
</div>
</body>
</html>效果圖:
6.陰陽八卦 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#baGua {
width: 96px;
height: 48px;
background: #eee;
border-color: red;
border-style: solid;
border-width: 2px 2px 50px 2px;
border-radius: 100%;
position: relative;
}
#baGua:before {
content: "";
position: absolute;
top: 50%;
left: 0;
background: #eee;
border: 18px solid red;
border-radius: 50%;
width: 12px;
height: 12px;
}
#baGua:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
background: red;
border: 18px solid #eee;
border-radius:100%;
width: 12px;
height: 12px;
}
</style>
</head>
<body>
<div id="baGua">
</div>
</body>
</html>效果圖:
7.無窮符號 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#wuQ{
position: relative;
width: 212px;
height: 100px;
}
#wuQ:before{
content: "";
position: absolute;
top: 0;
left: 0;
width: 60px;
height: 60px;
border: 20px solid red;
border-radius: 50px 50px 0 50px;
/*下右不變圓弧*/
transform: rotate(-45deg);
}
#wuQ:after{
content: "";
position: absolute;
top: 0;
right: 0;
width: 60px;
height: 60px;
border: 20px solid red;
border-radius: 50px 50px 50px 0;
/*下左不變圓弧*/
transform: rotate(45deg);
}
</style>
</head>
<body>
<div id="wuQ">
</div>
</body>
</html>效果圖:
以上就是css如何使用利用border和border-radius繪制一些小圖形(代碼實例)的詳細內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章! 網(wǎng)站建設(shè)是一個廣義的術(shù)語,涵蓋了許多不同的技能和學(xué)科中所使用的生產(chǎn)和維護的網(wǎng)站。 |
溫馨提示:喜歡本站的話,請收藏一下本站!