佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > html+css實(shí)現(xiàn)響應(yīng)式卡片懸停效果

html+css實(shí)現(xiàn)響應(yīng)式卡片懸停效果

熱門標(biāo)簽:智能手機(jī) 百度競(jìng)價(jià)點(diǎn)擊價(jià)格的計(jì)算公式 檢查注冊(cè)表項(xiàng) 硅谷的囚徒呼叫中心 網(wǎng)站建設(shè) 阿里云 使用U盤裝系統(tǒng) 美圖手機(jī)

話不多,看效果先:

卡片懸停,響應(yīng)式卡片,簡(jiǎn)約效果。

實(shí)現(xiàn):

1. 定義標(biāo)簽,.kapian為最底層盒子,然后兩個(gè)子盒子一個(gè)放圖片,一個(gè)放文本:

 

<div class="kapian">
          <div class="tu">
             <img src="3.2.png">
          </div>
          <div class="wenben">
                <h2>The aurora borealis</h2>
                <p style="padding-bottom: 20px;">natural</p>
                <p>
                    Aurora Borealis is a colorful luminous phenomenon that appears over the high magnetic latitude region of the planet's North Pole. 
                    I love the aurora borealis. It's so beautiful.
                    </p>
          </div>
    </div>

2.先定義底層盒子的css基本樣式,長(zhǎng)寬等,就不詳細(xì)說明了:

 

 .kapian{
            position: relative;
            width: 300px;
            height: 400px;
            border-radius: 3px;
            background-color: #fff;
            box-shadow: 2px 3px 3px rgb(139, 138, 138);
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s;
        }
        .kapian:hover{
            box-shadow: 2px 3px 10px rgb(36, 35, 35);
        }

:hover鼠標(biāo)經(jīng)過后盒子陰影變化。
transition: all 0.3s;過渡效果,陰影在0.3s內(nèi)慢慢變化

3. 圖片的基本樣式,采用絕對(duì)定位:

 

.tu{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 300px;
            overflow: hidden;
            
        }
        .tu img{
            width: 100%;
            height: 100%;
            transition: all 0.5s;
        }
        .kapian:hover .tu img{
            transform: scale(1.2);
            filter: blur(1px);
        }

:hover鼠標(biāo)經(jīng)過后圖片變大,而且變模糊;
transform: scale(1.2);圖片變大為1.2倍;
filter: blur(1px);圖片變模糊;

4 .定義裝文本這個(gè)盒子的基本樣式,采用絕對(duì)定位:

 

.wenben{
            position: absolute;
            bottom: -200px;
            width: 100%;
            height: 300px;
            background-color: rgb(247, 242, 242);
            transition: 0.5s;
        }
        .kapian:hover .wenben{
            bottom: 0px;
        }

:hover鼠標(biāo)經(jīng)過后文本框絕對(duì)定位的bottom發(fā)生改變,使得呈現(xiàn)文本框向上展開的效果;

5 .文本框里字符的樣式:

.wenben h2{
            color: rgb(21, 74, 172);
            line-height: 60px;
            text-align: center;

        }
        .wenben p{
            padding: 0 30px;
            font-family: 'fangsong';
            font-size: 16px;
            font-weight: bold;
            line-height: 20px;
            text-align: center;
        }

完整代碼:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
           background-image: radial-gradient(rgb(241, 238, 238),black);
        }
        .kapian{
            position: relative;
            width: 300px;
            height: 400px;
            border-radius: 3px;
            background-color: #fff;
            box-shadow: 2px 3px 3px rgb(139, 138, 138);
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s;
        }
        .kapian:hover{
            box-shadow: 2px 3px 10px rgb(36, 35, 35);
        }
        .tu{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 300px;
            overflow: hidden;
            
        }
        .tu img{
            width: 100%;
            height: 100%;
            transition: all 0.5s;
        }
        .kapian:hover .tu img{
            transform: scale(1.2);
            filter: blur(1px);
        }
        .wenben{
            position: absolute;
            bottom: -200px;
            width: 100%;
            height: 300px;

            background-color: rgb(247, 242, 242);
            transition: 0.5s;
        }
        .kapian:hover .wenben{
            bottom: 0px;
        }
        .wenben h2{
            color: rgb(21, 74, 172);
            line-height: 60px;
            text-align: center;

        }
        .wenben p{
            padding: 0 30px;
            font-family: 'fangsong';
            font-size: 16px;
            font-weight: bold;
            line-height: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="kapian">
          <div class="tu">
             <img src="3.2.png">
          </div>
          <div class="wenben">
                <h2>The aurora borealis</h2>
                <p style="padding-bottom: 20px;">natural</p>
                <p>
                    Aurora Borealis is a colorful luminous phenomenon that appears over the high magnetic latitude region of the planet's North Pole. 
                    I love the aurora borealis. It's so beautiful.
                    </p>
          </div>
    </div>
</body>
</html>

總結(jié):

希望在路上~

到此這篇關(guān)于 html+css實(shí)現(xiàn)響應(yīng)式卡片懸停效果的文章就介紹到這了,更多相關(guān)html css卡片懸停內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

標(biāo)簽:通遼 煙臺(tái) 懷化 黃山 湘潭 湖北 賀州 山南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《html+css實(shí)現(xiàn)響應(yīng)式卡片懸停效果》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    新平| SHOW| 巴里| 息烽县| 斗六市| 衡山县| 巍山| 广河县| 广昌县| 嘉禾县| 神农架林区| 盐津县| 永康市| 康乐县| 黄冈市| 榆中县| 昆山市| 建瓯市| 田东县| 朝阳市| 荆门市| 十堰市| 年辖:市辖区| 常熟市| 邹城市| 祁门县| 肥乡县| 泾阳县| 南川市| 武平县| 太谷县| 普定县| 漳浦县| 五常市| 高要市| 精河县| 项城市| 巴东县| 昌图县| 涪陵区| 扎兰屯市|