CSS特效(一)

三角形

<!-- log -->
<div class="tri"></div>

<style>
  .tri {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 100px;
    border-color: transparent;
    border-right-color: red;
  }
</style>

大盒套小盒

两个

<!-- log -->
<div class="wrapper">
  <div class="content"></div>
</div>

<style>
  .wrapper {
    padding: 100px;
    width: 100px;
    height: 100px;
    background-color: green;
  }
  .content {
    width: 100px;
    height: 100px;
    background-color: red;
  }
</style>

四个

<!-- log -->
<div class="div4">
  <div class="div3">
    <div class="div2">
      <div class="div1"></div>
    </div>
  </div>
</div>

<style>
  .div1 {
    width: 10px;
    height: 10px;
    background-color: white;
  }

  .div2 {
    width: 10px;
    height: 10px;
    padding: 10px;
    background-color: green;
  }

  .div3 {
    width: 30px;
    height: 30px;
    padding: 10px;
    background-color: white;
  }

  .div4 {
    width: 50px;
    height: 50px;
    padding: 10px;
    background-color: green;
  }
</style>

广告牌居中

<!-- log -->
<button id="banner-btn">点我显示居中</button>
<div class="banner"></div>

<style>
  .banner {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    margin-left: -50px;
    margin-top: -50px;
    background-color: red;
    width: 100px;
    height: 100px;
    z-index: 9999;
  }
</style>
<script>
  $('#banner-btn').click(function () {
    $('.banner').toggle()
  })
</script>
posted @ 2020-08-16 00:00  oceans-pro  阅读(131)  评论(0编辑  收藏  举报