day06

1.定位

 <style>
        div{
            width:100px;
            height: 100px;
            background: rosybrown;
            position: relative;
            left: 200px;
            top:200px;
            /*相對(duì)定位一般不使用right,bottom*/
            /*right:0px;*/
            /*bottom:0px;*/
        }
    </style>

<body>
    <!--定位-->
    <!--
        相對(duì)定位
        絕對(duì)定位
    -->
    <div>
        
    </div>
</body>

2.絕對(duì)定位

<style>
        .parent{
            width:200px;
            height: 200px;
            background-color: aquamarine;
            position: relative;
        }
        /*絕對(duì)定位的元素移動(dòng)的位置琢歇,是離它最經(jīng)的給了定位的父元素*/
        /*left,rigth,top,bottom*/
        .child{
            width:50px;
            height: 50px;
            background: green;
            position: absolute;
            right: 0;
            bottom: 0;
        }
    </style>

<body>
    <div class="parent">
        <div class="child">

        </div>
    </div>
</body>

3.元素垂直水平居中

<style>
        *{margin:0;padding:0}
        .parent{
            position: relative;
            width:300px;
            height:300px;
            background:rosybrown;
        }
        .child{
            position:absolute;
            width:50px;
            height: 50px;
            background: green;
            left: 50%;
            top: 50%;
            margin-left:-25px;
            margin-top:-25px;
        }
    </style>

<body>
    <div class="parent">
        <div class="child">
        
        </div>
     </div>
</body>

4.banner

<style>
        *{margin:0;padding:0}
        html,body{
            width: 100%;
            height: 100%;
        }
        img{
            position: absolute;
            left:50%;
            top:50%;
            width: 618px;
            height: 128px;
            margin-left: -307px;
            margin-right: -64px;
        }
        body{
            position:relative;
            background:url("images/bg.png") no-repeat center center;
            background-size: cover;
        }
    </style>

<body>
    <img src="images/phone.png" alt="">
</body>

5.search

 <style>
        *{margin:0;padding:0}
        .search{
            margin:100px;
            width:240px;
            height: 40px;
            position: relative;
        }
        button{
            position: absolute;
            top:50%;
            margin-top: -11px;
            right: 5px;
            width:23px;
            height: 22px;
            background: url("images/icon4.png");
            border:none;
        }
        input{
            padding-left: 20px;
            border: none;
            border-radius: 30px;
            outline: none;
            width: 220px;
            height: 40px;
            background: #eee;
        }

    </style>

<body>
    <div class="search">
        <input type="text" placeholder="搜索">
        <button></button>
    </div>
</body>

6.練習(xí)百度一下

<style>
        *{margin:0;padding:0}
        .search{
            margin-left: auto;
            margin-right: auto;
            margin-top:50px;
            width:640px;
            height: 38px;
            position: relative;
        }
        input{   
            border: 1px solid #b8b8b8; 
            width: 540px;
            height: 36px;
            position: absolute;
            left:0;
            top:0;
        }
        button{
            color: white;
            border:1px solid #3385ff;
            background: #3385ff; 
            width:23px;
            height: 22px;
            position: absolute;
            right: 0;
        }
       
    </style>
</head>
<body>
    <div class="search">
        <input type="text" placeholder="">
        <button>百度一下</button>
    </div>
</body>

7.fixed

<style>
        div{
            width:20px;
            height: 50px;
            background: red;
            position:fixed;
            right: 10px;
            bottom:130px;
        }
    </style>

<body>
    <div>

    </div>
</body>

8.z-index

<style>
        /*z-index設(shè)置給了absolute定位元素的堆疊順序*/
        .parent{
            width:300px;
            height: 300px;
            background: red;
            position: relative;
        }
        .one{
            width:100px;
            height: 100px;
            background:greenyellow;
            position:absolute;
            z-index: 100;
        }
        .two{
            width:200px;
            height: 50px;
            position:absolute;
            background: blueviolet;
            z-index: 101;
        }
        .parent:hover .one{
            z-index: 200;
        }


    </style>

<body>
    <!--z-index-->
    <div class="parent">
        <div class="one"></div>
        <div class="two"></div>
    </div>
</body>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末普碎,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子舷暮,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件薛夜,死亡現(xiàn)場(chǎng)離奇詭異速梗,居然都是意外死亡肮塞,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門姻锁,熙熙樓的掌柜王于貴愁眉苦臉地迎上來枕赵,“玉大人,你說我怎么就攤上這事位隶】酱埽” “怎么了?”我有些...
    開封第一講書人閱讀 163,711評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)篮昧。 經(jīng)常有香客問我赋荆,道長(zhǎng),這世上最難降的妖魔是什么恋谭? 我笑而不...
    開封第一講書人閱讀 58,380評(píng)論 1 293
  • 正文 為了忘掉前任糠睡,我火速辦了婚禮,結(jié)果婚禮上疚颊,老公的妹妹穿的比我還像新娘狈孔。我一直安慰自己,他們只是感情好材义,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,432評(píng)論 6 392
  • 文/花漫 我一把揭開白布均抽。 她就那樣靜靜地躺著,像睡著了一般其掂。 火紅的嫁衣襯著肌膚如雪油挥。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,301評(píng)論 1 301
  • 那天款熬,我揣著相機(jī)與錄音深寥,去河邊找鬼。 笑死贤牛,一個(gè)胖子當(dāng)著我的面吹牛惋鹅,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播殉簸,決...
    沈念sama閱讀 40,145評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼闰集,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了般卑?” 一聲冷哼從身側(cè)響起武鲁,我...
    開封第一講書人閱讀 39,008評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎蝠检,沒想到半個(gè)月后沐鼠,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,443評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡叹谁,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,649評(píng)論 3 334
  • 正文 我和宋清朗相戀三年饲梭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片本慕。...
    茶點(diǎn)故事閱讀 39,795評(píng)論 1 347
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡排拷,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出锅尘,到底是詐尸還是另有隱情监氢,我是刑警寧澤布蔗,帶...
    沈念sama閱讀 35,501評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站浪腐,受9級(jí)特大地震影響纵揍,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜议街,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,119評(píng)論 3 328
  • 文/蒙蒙 一泽谨、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧特漩,春花似錦吧雹、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,731評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至蛤售,卻和暖如春丁鹉,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背悴能。 一陣腳步聲響...
    開封第一講書人閱讀 32,865評(píng)論 1 269
  • 我被黑心中介騙來泰國(guó)打工揣钦, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人漠酿。 一個(gè)月前我還...
    沈念sama閱讀 47,899評(píng)論 2 370
  • 正文 我出身青樓冯凹,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親记靡。 傳聞我的和親對(duì)象是個(gè)殘疾皇子谈竿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,724評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • 1.相對(duì)定位 相對(duì)定位一般不使用right团驱,bottom 2.絕對(duì)定位 絕對(duì)定位的元素移動(dòng)的位置,是離它最近的給了...
    ZhouhaoJS閱讀 291評(píng)論 0 2
  • 今天所學(xué) 1.定位 1.1相對(duì)定位 相對(duì)定位就是元素在頁面上正常的位置 相對(duì)定位一般不使用right摸吠,bottom...
    chenghaojs閱讀 342評(píng)論 0 1
  • 今天學(xué)到了什么 1.定位 1.1相對(duì)定位 1.2絕對(duì)定位 2.元素垂直水平居中 3.banner 4.search...
    lyy_li閱讀 175評(píng)論 0 1
  • 知識(shí)要點(diǎn)梳理 1.相對(duì)定位 2.絕對(duì)定位 3.元素垂直水平居中 4.搜索框 百度搜索框 5.fixed 6.z-i...
    向陽_095c閱讀 160評(píng)論 0 0
  • 一.CSS中的定位 1.1相對(duì)定位(relative) 相對(duì)定位就是元素在頁面上正常的位置 1.2絕對(duì)定位 絕對(duì)定...
    小小全_閱讀 192評(píng)論 0 4