横向的选项卡效果

栏目: CSS · 发布时间: 6年前

核心属性

transform-origin: center right 页面参照其右侧中间位置

line-height: 1.5 设置文字的行间距为字体的1.5倍

display: none 隐藏默认的单选按钮

line-height: 5rem 使导航栏中的图标垂直居中

:checked + color + font-weight + left 选中某个选项卡改变图标的颜色,背景和粗细

:checked + display + transform + transition-delay 选中某个选项卡显示对应的页面

  1. <link rel="stylesheet" media="screen" href="https://cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css" />
  2. <section>
  3. <input type="radio" id="profile" value="1" name="tractor" checked='checked' />
  4. <input type="radio" id="settings" value="2" name="tractor" />
  5. <input type="radio" id="posts" value="3" name="tractor" />
  6. <input type="radio" id="books" value="4" name="tractor" />
  7. <nav>
  8. <label for="profile" class='fa fa-camera-retro'></label>
  9. <label for="settings" class='fa fa-film'></label>
  10. <label for="posts" class='fa fa-calendar'></label>
  11. <label for="books" class='fa fa-list-alt'></label>
  12. </nav>
  13. <article class='uno'>
  14. <h2>
  15. CSS选项卡
  16. </h2>
  17. <footer>
  18. <ul>
  19. <li class='fa fa-link'></li>
  20. <li class='fa fa-bar-chart'></li>
  21. <li class='fa fa-sitemap'></li>
  22. <li class='fa fa-wrench'></li>
  23. <li class='fa fa-magic'></li>
  24. </ul>
  25. </footer>
  26. </article>
  27. <article class='dos fa fa-wrench'>
  28. <p>如果有什么网络现象是最接近的,那就是博客,课程和网络教学。关于传播人类知识的任何东西或领域,无论是Angelical还是Mefistofélico,都有自己的提议、他们的“老师”和他们有远见的老师。</p>
  29. </article>
  30. <article class='tres fa fa-beer'>
  31. <ol>
  32. <li>CSS图像和物体的尺寸</li>
  33. <li>在做CSS时避免不必要的点击</li>
  34. <li>CSS是什么?</li>
  35. <li>CSS属性规格说明</li>
  36. <li>一个input多个label</li>
  37. <li>CSS句法和词汇表</li>
  38. </ol>
  39. </article>
  40. <article class='cuatro fa fa-copy'>
  41. <dl>
  42. <dt>CSS过渡指南</dt>
  43. <dd>每一个CSS属性组成的过渡组与DEMOS。</dd>
  44. <dt>@Font-face及其问题</dt>
  45. <dd>最常见的问题及其解决办法,通常是通过使用CSS@font-face规则来显示除Safety Fonts以外的其他字体。</dd>
  46. </dl>
  47. </article>
  48. </section>
  1. *, *:after, *:before {
  2. box-sizing: border-box;
  3. }
  4. * {
  5. margin:0;
  6. padding:0;
  7. border: 0 none;
  8. position: relative;
  9. }
  10. html {
  11. background: #f5f5f5;
  12. width: 100%;
  13. height: 100%;
  14. font-weight: 300;
  15. color: #fff;
  16. }
  17. section {
  18. background: #31A66C;
  19. width: 80vw;
  20. max-width: 40rem;
  21. min-width: 390px;
  22. height: 25rem;
  23. margin: 4rem auto;
  24. box-shadow: 0 0 6px rgba(0,0,0,.4);
  25. }
  26. article {
  27. position: absolute;
  28. left: 0;
  29. top: 5rem;
  30. right: 0;
  31. bottom: 0;
  32. padding: 1rem 2rem 0;
  33. overflow: auto;
  34. transition: .7s;
  35. transform: scale(0);
  36. transform-origin: center right;
  37. transition-delay: .1s;
  38. }
  39. article:before {
  40. position: absolute;
  41. bottom: 1rem;
  42. right: 1rem;
  43. color: rgba(0,0,0,.2);
  44. font-size: 4rem;
  45. font-weight: 100;
  46. }
  47. h2 {
  48. font-size: 2.5rem;
  49. font-weight: 600;
  50. text-align: center;
  51. color: rgba(0,0,0,.6);
  52. }
  53. footer ul {
  54. width: 100%;
  55. color: #037B49;
  56. margin-top: 50px;
  57. }
  58. footer li {
  59. list-style-type: none;
  60. float: left;
  61. width: 20%;
  62. }
  63. footer li::before {
  64. display: block;
  65. text-align: center;
  66. font-size: 3rem;
  67. font-weight: 100;
  68. }
  69. p, dl, ol {
  70. line-height: 1.5;
  71. font-size: 1.3rem;
  72. }
  73. ol li {
  74. margin: 0 0 .5rem 1rem;
  75. }
  76. dt {
  77. font-size: 1.6rem;
  78. font-weight: 600;
  79. text-indent: 1.5rem;
  80. }
  81. nav {
  82. background: #fff;
  83. width: 100%;
  84. height: 5rem;
  85. box-shadow: 0 0 6px rgba(0,0,0,.4);
  86. }
  87. nav:after {
  88. content:'';
  89. width: 25%;
  90. height: 5rem;
  91. background: #BEE3D1;
  92. position: absolute;
  93. transition: .5s;
  94. }
  95. input {
  96. display: none;
  97. }
  98. label {
  99. width: 25%;
  100. float: left;
  101. color: #BEE3D1;
  102. text-align: center;
  103. cursor: pointer;
  104. transition: .5s;
  105. z-index: 2;
  106. }
  107. label:hover {color: #1E6743;}
  108. label:before {
  109. display: block;
  110. font-size: 3rem;
  111. line-height: 5rem;
  112. z-index: 2;
  113. }
  114. #profile:checked ~ nav [for='profile'],
  115. #settings:checked ~ nav [for='settings'],
  116. #posts:checked ~ nav [for='posts'],
  117. #books:checked ~ nav [for='books'] {
  118. color: #1E6743;
  119. font-weight: 600;
  120. }
  121. #profile:checked ~ nav:after {
  122. left: 0;
  123. }
  124. #settings:checked ~ nav:after {
  125. left: 25%;
  126. }
  127. #posts:checked ~ nav:after {
  128. left: 50%;
  129. }
  130. #books:checked ~ nav:after {
  131. left: 75%;
  132. }
  133. #profile:checked ~ .uno,
  134. #settings:checked ~ .dos,
  135. #posts:checked ~ .tres,
  136. #books:checked ~ .cuatro {
  137. display: block;
  138. transform: scale(1);
  139. transition-delay: .5s;
  140. }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Convergence Culture

Convergence Culture

Henry Jenkins / NYU Press / 2006-08-01 / USD 30.00

"Convergence Culture" maps a new territory: where old and new media intersect, where grassroots and corporate media collide, where the power of the media producer, and the power of the consumer intera......一起来看看 《Convergence Culture》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换