CSS應用案例

表單美化

  • 如果body不能直接撐起高,給html標簽添加height:100%

  • filter是濾鏡,針對的元素里面的所有內容若锁,默認是0px

  • 效果使用background-clip: content-box;,同時設置padding值.clip:裁切

    效果

  • 使用定位劇中的方法:leftmargin配合使用。

  • background: linear-gradient(red 10%,red 20%,green 20%,green 40%,blue 40%);
    background: linear-gradient(transparent 0%,transparent 10%, black 10%,black 11%,transparent 11%);

.father{
display:flex;
}
.son{
            flex:1;
}
            flex: 1;
            /*

            flex決定了寬度

            根據(jù)當前富裕寬度[剩余可利用空間]/當前 fiex總和邓萨。
            */
  • outline是輪廓。像input標簽的點擊淺藍色就可以通過設置outline清除掉

//獲得焦點之后菊卷,執(zhí)行CSS
    <style>
        .input1{
            outline: none;
            border: none;
            height: 50px;
            border-bottom: 1px solid black;
        }

        .input1:focus{
            border-bottom-color: red;
        }
        
        .input1::-webkit-input-placeholder{
            transition: .5s;
        }
        .input1:focus::-webkit-input-placeholder{
            transform: scale(0.7) translateY(-10px);
            transform-origin: left top;
        }
    </style>
</head>
<body>
<input type="text" class="input1" placeholder="請輸入賬號" >
</body>

詳盡代碼

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表單美化2</title>
    <style>
        *{
            margin: 0px;
            top: 0px;
        }
        html{
            height: 100%;
        }
        body{
            height: 100%;
        }
        .mask{
            width: 100%;
            height: 100%;
            background-image: url("img/bg.jpg");
            background-size: cover;
            filter: blur(5px);/*這個是添加的濾鏡*/
        }
        .drog{
            position: absolute;
            left: 0px;
            top: 0px;
            width: 640px;
            height: 620px;
            border: 1px solid white;
            background-color: rgba(255,255,255,0.8);
            background-clip: content-box;/*規(guī)定背景圖的繪制區(qū)域*/
            padding: 10px;
            left: 50%;
            top: 50%;
            margin-left: -320px;
            margin-top: -310px;
            border-radius: 10px;
        }
        .title{
            text-align: center;
            font-size: 28px;
            margin: 24px 0px;
            display: flex;
        }

        .title .title_name{
            padding: 0px 10px;
        }
        .title .line{
            background: linear-gradient(transparent 49%,black 49%,black 50%,transparent 50%);
            flex:1;
        }

        table{
            width: 100%;
        }
        .td_left{
            text-align: right;
            width: 150px;
        }

        .userInput{
            outline: none;
            height: 40px;
            border:none;
            border-bottom: 1px solid black;
            background-color: rgba(255,255,255,0);
        }
        .userInput:focus{
            border-bottom-color: red;
        }

        .userInput::-webkit-input-placeholder{
            transition: .5s;
        }
        .userInput:focus::-webkit-input-placeholder{
            transform: scale(0.7) translateY(-10px);
            transform-origin: left top;
        }

        /*單選框修改*/
        .chooseGender input{
            display: none;
        }
        .chooseGender label{
            width: 8px;
            height: 8px;
            margin: 1px;
            border: 1px solid #000;
            display: inline-block;
            border-radius: 50%;
            position: relative;
        }

        .chooseGender input:checked +label{
            border-color: #888;
        }
        .chooseGender input:checked+label:before{
            content: '';
            width: 4px;
            height: 4px;
            background-color: red;
            display: inline-block;
            position: absolute;
            border-radius: 50%;
            left: 2px;
            top: 2px;
        }
        /*單選框修改結束*/


        /*多選框修改*/
        .chooseGreens input{
            display: none;
        }
        .chooseGreens label{
            width: 9px;
            height: 9px;
            margin: 1px 1px 0px 1px;
            border: 1px solid dimgrey;
            display: inline-block;
        }
        .chooseGreens input:checked+label{
            border-color: #000;
            position: relative;
        }
        .chooseGreens input:checked +label:before{
            content: '';
            width: 2px;
            height: 7px;
            background-color: red;
            display: inline-block;
            position: absolute;
            transform: rotate(-37deg);
            top: 1px;
            left: 2px;
        }
        .chooseGreens input:checked +label:after{
            content: '';
            width: 2px;
            height: 7px;
            background-color: red;
            display: inline-block;
            position: absolute;
            transform: rotate(29deg);
            top: 1px;
            left: 5px;
        }
        /*單選框修改結束*/


        /*開關效果開始*/
        .addressHidden #addHidd{
            display: none;
        }
        .addressHidden label{
            width: 40px;
            height: 20px;
            border: 1px solid #888;
            display: inline-block;
            border-radius: 15px;
        }
        .addressHidden label span{
            width: 20px;
            height: 20px;
            display: inline-block;
            border-radius: 15px;
            box-shadow: 1px 1px 1px  #ccc;
            background-color: white;
            transition:all  0.5s;

        }
        .addressHidden #addHidd:checked+label{
            background-color: greenyellow;
        }
        .addressHidden #addHidd:checked+label span{
            transform: translateX(20px);
        }
        /*開關效果結束*/

        /*
        開關效果帶文字
        */

        .shareToNet #shareNet{
            display: none;
        }
        .shareToNet label{
            display: inline-block;
            width: 40px;
            height: 20px;
            border: 1px solid #888;
            border-radius: 15px;
            transition: 0.3s;
        }
        .shareToNet label .move{
            display: block;
            width: 20px;
            height: 20px;
            box-shadow: 1px 1px 1px #ccc;
            border-radius: 50%;
            background: white;
            transition: 0.3s;
            overflow: hidden;
        }

        .shareToNet #shareNet:checked+label{
            background-color: greenyellow;
        }

        .shareToNet input:checked+label .move{
            transform: translateX(20px);
            box-shadow: none;
        }

        em{
            font-size: 12px;
            font-style: normal;
            float: left;
            width: 50%;
        }
        .shareToNet input:checked+label .move span{
            transform: translateX(-20px);

        }
       .shareToNet .move span{
            width: 40px;
            display: block;
            height: 20px;
            text-align: center;
            transition: .3s;
            /*transform: translateX(-20px);*/
        }

    </style>
</head>
<body>
<div class="mask"></div>

<div class="drog">
    <h2 class="title">
        <span class="line"></span>
        <span class="title_name">用戶注冊</span>
        <span class="line"></span>
    </h2>

    <table>
        <tbody>
        <tr>
            <td class="td_left">姓名:</td>
            <td><input type="text" placeholder="請輸入姓名" class="userInput"></td>
        </tr>

        <tr>
            <td class="td_left">密碼:</td>
            <td><input type="text" placeholder="請輸入密碼" class="userInput"></td>
        </tr>

        <tr>
            <td class="td_left">確認密碼:</td>
            <td><input type="text" placeholder="請確認密碼" class="userInput"></td>
        </tr>

        <tr>
            <td class="td_left">性別選擇:</td>
            <td class="chooseGender">
                <input type="radio" name="gender" id="chooseMan">
                <label for="chooseMan"></label>男
                <input type="radio" name="gender" id="chooseGirl">
                <label for="chooseGirl"></label>女
            </td>
        </tr>

        <tr>
            <td class="td_left">喜愛的菜系:</td>
            <td class="chooseGreens">
                <input type="checkbox" name="greens" id="food_z">
                <label for="food_z"></label>浙菜
                <input type="checkbox" name="greens" id="food_x">
                <label for="food_x"></label>湘菜
                <input type="checkbox" name="greens" id="food_y">
                <label for="food_y"></label>粵菜
                <input type="checkbox" name="greens" id="food_j">
                <label for="food_j"></label>京菜
                <input type="checkbox" name="greens" id="food_s">
                <label for="food_s"></label>蘇菜
            </td>
        </tr>

        <tr>
            <td class="td_left">個人簡介:</td>
            <td>
                <textarea cols="30" rows="10"></textarea>

            </td>
        </tr>

        <tr>
            <td class="td_left">地址匿名:</td>
            <td class="addressHidden">
                <input type="checkbox" id="addHidd">
                <label for="addHidd">
                    <span></span>
                </label>
            </td>
        </tr>


        <tr>
            <td class="td_left">分享到社交網絡:</td>
            <td class="shareToNet">
                <input type="checkbox" id="shareNet">
                <label for="shareNet">
                    <span class="move">
                        <span>
                            <em>on</em>
                            <em>off</em>
                        </span>
                    </span>
                </label>
            </td>
        </tr>

        <tr>
            <td class="td_left"></td>
            <td>
                <input type="submit">
                <input type="reset">
            </td>
        </tr>

        </tbody>
    </table>
</div>
</body>
</html>
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末缔恳,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子的烁,更是在濱河造成了極大的恐慌褐耳,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件渴庆,死亡現(xiàn)場離奇詭異铃芦,居然都是意外死亡,警方通過查閱死者的電腦和手機襟雷,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進店門刃滓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人耸弄,你說我怎么就攤上這事咧虎。” “怎么了计呈?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵砰诵,是天一觀的道長。 經常有香客問我捌显,道長茁彭,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任扶歪,我火速辦了婚禮理肺,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己妹萨,他們只是感情好年枕,可當我...
    茶點故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著乎完,像睡著了一般熏兄。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上囱怕,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天霍弹,我揣著相機與錄音,去河邊找鬼娃弓。 笑死典格,一個胖子當著我的面吹牛,可吹牛的內容都是我干的台丛。 我是一名探鬼主播耍缴,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼挽霉!你這毒婦竟也來了防嗡?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤侠坎,失蹤者是張志新(化名)和其女友劉穎蚁趁,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體实胸,經...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡他嫡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了庐完。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片钢属。...
    茶點故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖门躯,靈堂內的尸體忽然破棺而出淆党,到底是詐尸還是另有隱情,我是刑警寧澤讶凉,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布染乌,位于F島的核電站,受9級特大地震影響懂讯,放射性物質發(fā)生泄漏慕匠。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一域醇、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦譬挚、人聲如沸锅铅。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽盐须。三九已至,卻和暖如春漆腌,著一層夾襖步出監(jiān)牢的瞬間贼邓,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工闷尿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留塑径,地道東北人。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓填具,卻偏偏與公主長得像统舀,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子劳景,可洞房花燭夜當晚...
    茶點故事閱讀 45,440評論 2 359

推薦閱讀更多精彩內容

  • 1誉简、垂直對齊 如果你用CSS,則你會有困惑:我該怎么垂直對齊容器中的元素盟广?現(xiàn)在闷串,利用CSS3的Transform,...
    kiddings閱讀 3,169評論 0 11
  • 問答題47 /72 常見瀏覽器兼容性問題與解決方案筋量? 參考答案 (1)瀏覽器兼容問題一:不同瀏覽器的標簽默認的外補...
    _Yfling閱讀 13,756評論 1 92
  • 選擇qi:是表達式 標簽選擇器 類選擇器 屬性選擇器 繼承屬性: color烹吵,font,text-align毛甲,li...
    love2013閱讀 2,316評論 0 11
  • 這篇文字里我會介紹50 個便于使用的 CSS2/CSS3 代碼片段給所有的WEB專業(yè)人員. 選擇IDE開發(fā)環(huán)境來存...
    JamHsiao_aaa4閱讀 1,128評論 0 3
  • “你怎么那么慢年叮,塊點!”“知道了玻募!后媽真是不好(小聲)”“你說什么只损?”“沒,沒什么”“哼七咧,你最好給我老實點跃惫,今天學...
    cptbtptpbc閱讀 203評論 0 0