css完成js效果

1.用css完成js的tab切換

<style>
.tabs {
  position: relative;  
   /*set height to be even for all tab groups*/
  min-height: 180px;
  display: block;
  margin: 1em auto 0;
  width: 460px;
}

.tab {
  float: left;
   
}

.tab label {
  cursor: pointer;
  background: #c69;
  font-size: 1.2em;
  border-radius: 5px 5px 0 0;
  padding: .5em 1em;
}

.tab [type=radio] {
  position: absolute;
  height: 0;
  width: 0;
  overflow: hidden;
  
 
}

.content {
  background: wheat;
  border: 1px solid #c69;
  border-radius: 0 5px 5px;
  padding: .5em 2em;
  max-width: 450px;
  position: absolute;
  top: 2em; left: 0; right: 0; bottom: 0;
  
}

[type=radio]:checked ~ label {
  z-index: 2;
  background: #c99;
}

[type=radio]:checked ~ label ~ .content {
  z-index: 1;
  opacity: 1;
}

body {
  font-family: monospace;
  font-size: 1.1em;
}
</style>
</head>
<body>
<div class="tabs">    
   <div class="tab">
       <input type="radio" name="tabgroup" id="tab-1" checked>
       <label for="tab-1">One</label>
       <div class="content">
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum debitis dignissimos velit quasi vel! Ipsum illo vero amet cumque voluptatem accusamus dignissimos nisi quam adipisci aperiam! Temporibus necessitatibus deleniti excepturi.</p>
       </div> 
   </div>
    
   <div class="tab">
       <input type="radio" name="tabgroup" id="tab-2">
       <label for="tab-2">Two</label>
       <div class="content">
           <p>Hi there! Fancy seeing you here!</p>
       </div> 
   </div>
    
    <div class="tab">
       <input type="radio" name="tabgroup" id="tab-3">
       <label for="tab-3">Three</label>
       <div class="content">
           <p>Tempora minima itaque officia aliquid, facilis, enim atque. Quibusdam velit quo alias, laboriosam non nobis, dolorem itaque commodi ullam, corporis tempore sapiente doloribus libero cupiditate doloremque tempora. Reiciendis, ab, modi.</p>
       </div> 
    </div>
</div>
</body>
</html>

點擊效果

2. css無縫滾動

<style>
    #slider
    {
        width: 300px;
        height: 200px;
        overflow: hidden;
        border:1px solid;
    }
    .wrap
    {
        width: 900px;
        height: 200px;
        position: relative;
        left:0px;
        animation-name:animation;//指定由@keyframes描述的關鍵幀名稱州袒。
        animation-iteration-count:infinite;//置動畫重復次數(shù)揭绑, 可以指定infinite無限次重復動畫
        animation-duration: 6s;//設置動畫一個周期的時長。
        animation-direction:alternate;//設置動畫在每次運行完后是反向運行還是重新回到開始位置重復運行郎哭。*//*normal | reverse | alternate | alternate-reverse

    }
    .slide
    {
        width:300px;
        height: 200px;
        float: left;
        outline: 1px solid red;
    }
    .slide:nth-child(1)
    {
        background: green;
    }
    .slide:nth-child(2)
    {
        background: grey;
    }
    .slide:nth-child(3)
    {
        background: yellow;
    }
    @keyframes animation//關鍵幀
    {
        0%{left:0px;}
        50%{left:-300px;}
        100%{left:-600px;}
        
    }
</style>
</head>
<body>
    <div id="slider">
        <div class="wrap">
            <div class="slide">1</div>
            <div class="slide">2</div>
            <div class="slide">3</div>
        </div>
    </div>
</body>
</html>

點擊效果

3. cs實現(xiàn)點擊li切換背景圖片

<style>
    #slider
    {
        position: relative;
    }
    .slide
    {
        width: 300px;
        height: 200px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 0;
    }
    .slide:target
    {
        z-index: 1;
    }
    .slide:nth-child(1)
    {
        background: red;
    }
    .slide:nth-child(2)
    {
        background: pink;
    }
    .slide:nth-child(3)
    {
        background: green;
    }
    .slide:nth-child(4)
    {
        background: #ccc;
    }
    ul
    {
        position: absolute;
        top:0;
        left: 0;
        z-index: 2;
    }
    ul a
    {
        color: white;
    }
</style>
</head>
<body>
    <div id="slider">
        <div class="slide" id="slider-1">1</div>
        <div class="slide" id="slider-2">2</div>
        <div class="slide" id="slider-3">3</div>
        <div class="slide" id="slider-4">4</div>
        <ul>
            <li><a href="#slider-1">1</a></li>
            <li><a href="#slider-2">2</a></li>
            <li><a href="#slider-3">3</a></li>
            <li><a href="#slider-4">4</a></li>
        </ul>
    </div>
</body>
</html>

點擊效果

4. 點擊圖標LightBox

<style>

 

.thumbnail {
  max-width: 50px;
  margin: 0 auto;
  display: block;
}

.lightbox {
 /* Hide lightbox image*/
    display: none;

 /*   Position/style of lightbox*/
    position: fixed;
    z-index: 999;
    width: 100%;
    height: 100%;
    text-align: center;
    top: 0;
    left: 0;
    background: rgba(0,0,0,.8);;
}

.lightbox img {
   /* Pad the lightbox image*/
    max-width: 90%;
    max-height: 80%;
    margin-top: 30%;
}

.lightbox:target {
   /*  Remove default outline and unhide lightbox*/
    outline: none;
    display: block;
}
</style>
</head>
<body>
    <!-- thumbnail image wrapped in a link -->
<a href="#img1">
  ![](../img/normal.png)
</a>

<!-- lightbox container hidden with CSS -->
<a href="#" class="lightbox" id="img1">
  ![](../img/normal.png)
</a>
</body>
</html>

點擊效果

5.css- color-picker

<style>


[type="submit"] {
  background-color: wheat;
  padding: .4em;
  border: none;
}

form {
  width: 50%;
  display: block;
  margin: 0 auto;
}

input
 {
  width: 100%;
  margin-bottom: 1em;
}
</style>
</head>
<body>
   <form>
     <input type="color" aria-label="Select a color">
     <button type="submit">Submit</button>
   </form> 
</body>
</html>

點擊效果

6. target

<style>
 a
 {
    display: block;
    padding: 2em 1em;
    background: green;
    color:white;
    border-bottom: 1px solid;
    text-decoration: none;
 }
 div
 {
    background: #ccc;
    height:0px;
    transition:height 2s;
    overflow: hidden;
 }
 div:target
 {
    height: 400px;
 }
</style>
</head>
<body>
 <a href="#div1">div1</a>
 <div id="div1">我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳</div> 
  <a href="#div2">div2</a>
 <div id="div2">我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳</div>   
</body>
 <a href="#div3">div3</a>
 <div id="div3">我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳 我愛琳琳</div>   
</body>  
</body>
</html>

點擊效果

7.Modal

<style>
  body,p
  {
    margin: 0;
    padding:0;
  }
  a
  {
    text-decoration: none;
  }
 .click
 {
    display: block;
    width: 100px;
    height: 100px;
    background: black;
    color: white;   
    position: absolute;
    top:50%;
    left: 50%;
    margin-left: -50px;
    margin-top:-50px;
    line-height: 100px;
    text-align: center;

 }
 .intered
 {
    height: 100%;
    width: 100%;
    background: red;
    font-size: 24px;
    position: fixed;
    top:0;
    text-align: center;
    display: none;

 }
 .intered p
 {
    margin: 20% 0;
 }
 #inter:target
 {
    display: block;
 }
</style>
</head>
<body>
 <a href="#inter" class="click" >open me</a>
 <div id="inter" class="intered">
    <p>Hello wrold</p>
    <a href="#interClose">close</a>
 </div>
</body>
</html>

點擊效果

版權饑人谷--楠柒所有如有轉載請注明出處謝謝

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末他匪,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子夸研,更是在濱河造成了極大的恐慌邦蜜,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件亥至,死亡現(xiàn)場離奇詭異畦徘,居然都是意外死亡,警方通過查閱死者的電腦和手機抬闯,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評論 3 393
  • 文/潘曉璐 我一進店門井辆,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人溶握,你說我怎么就攤上這事杯缺。” “怎么了睡榆?”我有些...
    開封第一講書人閱讀 163,711評論 0 353
  • 文/不壞的土叔 我叫張陵萍肆,是天一觀的道長。 經(jīng)常有香客問我胀屿,道長塘揣,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,380評論 1 293
  • 正文 為了忘掉前任宿崭,我火速辦了婚禮亲铡,結果婚禮上,老公的妹妹穿的比我還像新娘葡兑。我一直安慰自己奖蔓,他們只是感情好,可當我...
    茶點故事閱讀 67,432評論 6 392
  • 文/花漫 我一把揭開白布讹堤。 她就那樣靜靜地躺著吆鹤,像睡著了一般。 火紅的嫁衣襯著肌膚如雪洲守。 梳的紋絲不亂的頭發(fā)上疑务,一...
    開封第一講書人閱讀 51,301評論 1 301
  • 那天沾凄,我揣著相機與錄音,去河邊找鬼知允。 笑死搭独,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的廊镜。 我是一名探鬼主播牙肝,決...
    沈念sama閱讀 40,145評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼嗤朴!你這毒婦竟也來了配椭?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,008評論 0 276
  • 序言:老撾萬榮一對情侶失蹤雹姊,失蹤者是張志新(化名)和其女友劉穎股缸,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體吱雏,經(jīng)...
    沈念sama閱讀 45,443評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡敦姻,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,649評論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了歧杏。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片镰惦。...
    茶點故事閱讀 39,795評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖犬绒,靈堂內(nèi)的尸體忽然破棺而出旺入,到底是詐尸還是另有隱情,我是刑警寧澤凯力,帶...
    沈念sama閱讀 35,501評論 5 345
  • 正文 年R本政府宣布茵瘾,位于F島的核電站,受9級特大地震影響咐鹤,放射性物質發(fā)生泄漏拗秘。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,119評論 3 328
  • 文/蒙蒙 一祈惶、第九天 我趴在偏房一處隱蔽的房頂上張望雕旨。 院中可真熱鬧,春花似錦行瑞、人聲如沸奸腺。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,731評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至帮非,卻和暖如春氧吐,著一層夾襖步出監(jiān)牢的瞬間讹蘑,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,865評論 1 269
  • 我被黑心中介騙來泰國打工筑舅, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留座慰,地道東北人。 一個月前我還...
    沈念sama閱讀 47,899評論 2 370
  • 正文 我出身青樓翠拣,卻偏偏與公主長得像版仔,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子误墓,可洞房花燭夜當晚...
    茶點故事閱讀 44,724評論 2 354

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