欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

css中position有哪些不同的值-創(chuàng)新互聯(lián)

今天就跟大家聊聊有關(guān)css中position有哪些不同的值,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對(duì)外擴(kuò)展宣傳的重要窗口,一個(gè)合格的網(wǎng)站不僅僅能為公司帶來(lái)巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺(tái),成都創(chuàng)新互聯(lián)公司面向各種領(lǐng)域:成都房屋鑒定網(wǎng)站設(shè)計(jì)全網(wǎng)營(yíng)銷推廣解決方案、網(wǎng)站設(shè)計(jì)等建站排名服務(wù)。

position屬性

position屬性指定用于元素的定位方法的類型(靜態(tài),相對(duì),固定,絕對(duì)或粘性)。 有五種不同的值:

•static
•relative
•fixed
•absolute
•sticky

然后使用top,bottom,left和right屬性定位元素。但是,除非首先設(shè)置position屬性,否則這些屬性將不起作用。根據(jù)位置值,它們的工作方式也不同。

position:static;

默認(rèn)情況下,HTML元素定位為靜態(tài)。靜態(tài)定位元素不受top,bottom,left和right屬性的影響。 元素position:static;沒(méi)有以任何特殊方式定位; 它總是根據(jù)頁(yè)面的正常流程定位:

這個(gè)<div>元素的position:static;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>css</title>
    <style>
        div.static {
            position: static;
            border: 3px solid #73AD21;
        }
    </style>
</head>
<body>
<h3>position: static;</h3>
<p>一個(gè)位置為position:static; 沒(méi)有任何特殊的定位; 它是始終根據(jù)頁(yè)面的正常流程定位:</p>
<div class="static">
    這個(gè)div元素的位置為:static;
</div>
</body>
</html>

position:relative;

具有position:relative;相對(duì)于其正常位置定位的元素。設(shè)置相對(duì)定位元素的top,bottom,left和right屬性將使其遠(yuǎn)離其正常位置進(jìn)行調(diào)整。其他內(nèi)容不會(huì)被調(diào)整以適應(yīng)元素留下的任何空白。

這個(gè)<div>元素的position:relative;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>css</title>
    <style>
        div.relative {
            position: relative;
            left: 30px;
            border: 3px solid #73AD21;
        }
    </style>
</head>
<body>
<h3>position: relative;</h3>
<p>position:relative的元素; 相對(duì)于其正常位置定位:</p>
<div class="relative">
    這個(gè)div元素有position: relative;
</div>
</body>
</html>

position:fixed;

元素position:fixed;相對(duì)于視口定位,這意味著即使頁(yè)面滾動(dòng),它也始終保持在同一位置。top,bottom,left和right屬性用于定位元素。固定元素不會(huì)在頁(yè)面中留下通常位于其中的間隙。注意頁(yè)面右下角的固定元素。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>css教程(jc2182.com)</title>
    <style>
        div.fixed {
            position: fixed;
            bottom: 0;
            right: 0;
            width: 300px;
            border: 3px solid #73AD21;
        }
    </style>
</head>
<body>
<h3>position:fixed;</h3>
<p>position:fixed; 相對(duì)于視口定位,這意味著即使頁(yè)面滾動(dòng),它也始終保持在同一位置:</p>
<div class="fixed">
    這個(gè)div元素有position: fixed;
</div>
</body>
</html>

position:absolute;

具有position:absolute;相對(duì)于最近定位的祖先定位的元素(而不是相對(duì)于視口定位,如fixed)。然而; 如果絕對(duì)定位元素沒(méi)有定位祖先,它將使用文檔正文,并隨頁(yè)面滾動(dòng)一起移動(dòng)。 注意: “定位”元素的位置是除了static之外的任何元素。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>css教程(jc2182.com)</title>
    <style>
        div.relative {
            position: relative;
            width: 400px;
            height: 200px;
            border: 3px solid #73AD21;
        }
        div.absolute {
            position: absolute;
            top: 80px;
            right: 0;
            width: 200px;
            height: 100px;
            border: 3px solid #73AD21;
        }
    </style>
</head>
<body>
<h3>position: absolute;</h3>
<p>position:absolute;的元素; 相對(duì)于最近定位的祖先定位(而不是相對(duì)于視口定位,如fixed):</p>
<div class="relative">這個(gè)div元素有 position: relative;
    <div class="absolute">這個(gè)div元素有 position: absolute;</div>
</div>
</body>
</html>

position:sticky;

position:sticky;根據(jù)用戶的滾動(dòng)位置定位元素。粘性元素在relative和之間切換fixed,具體取決于滾動(dòng)位置。它被相對(duì)定位,直到在視口中滿足給定的偏移位置 - 然后它“粘住”到位(如位置:fixed)。

注意: Internet Explorer,Edge 15及更早版本不支持粘性定位。Safari需要-webkit-前綴(參見(jiàn)下面的示例)。您還必須指定的至少一個(gè)top,right,bottom或left為粘稠的定位工作。

在此示例中,top: 0當(dāng)您到達(dá)其滾動(dòng)位置時(shí),粘性元素會(huì)粘到頁(yè)面頂部。

<!DOCTYPE html>
<html>
<head>
    <style>
        div.sticky {
            position: -webkit-sticky;
            position: sticky;
            top: 0;
            padding: 5px;
            background-color: #cae8ca;
            border: 2px solid #4CAF50;
        }
    </style>
</head>
<body>
<p>嘗試在此框架內(nèi)<b>滾動(dòng)</b>以了解粘性定位的工作原理。</p>
<p>注意:IE/Edge15及更早版本不支position: sticky;。</p>
<div class="sticky">我很粘!</div>
<div style="padding-bottom:2000px">
    <p>在此示例中,當(dāng)您到達(dá)其滾動(dòng)位置時(shí),粘性元素會(huì)粘到頁(yè)面頂部(頂部:0)。</p>
    <p>向上滾動(dòng)以消除粘性。</p>
    <p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
    <p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
    <p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
    <p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
</div>
</body>
</html>

在線體驗(yàn)一下達(dá)到其滾動(dòng)位置

所有CSS定位屬性

屬性描述
bottom設(shè)置定位框的底部邊緣
clip剪輯一個(gè)絕對(duì)定位的元素
left設(shè)置定位框的左邊緣
position指定元素的定位類型
right設(shè)置定位框的右邊緣
top設(shè)置定位框的上邊緣
z-index設(shè)置元素的堆棧順序

css的基本語(yǔ)法是什么

css的基本語(yǔ)法是:1、css規(guī)則由選擇器和一條或多條聲明兩個(gè)部分構(gòu)成;2、選擇器通常是需要改變樣式的HTML元素;3、每條聲明由一個(gè)屬性和一個(gè)值組成;4、屬性和屬性值被冒號(hào)分隔開(kāi)。

看完上述內(nèi)容,你們對(duì)css中position有哪些不同的值有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

網(wǎng)頁(yè)題目:css中position有哪些不同的值-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)鏈接:http://www.chinadenli.net/article16/dgiddg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名網(wǎng)站內(nèi)鏈App設(shè)計(jì)云服務(wù)器全網(wǎng)營(yíng)銷推廣品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)