<bdo id='KzRwa'></bdo><ul id='KzRwa'></ul>
  • <legend id='KzRwa'><style id='KzRwa'><dir id='KzRwa'><q id='KzRwa'></q></dir></style></legend>

      1. <i id='KzRwa'><tr id='KzRwa'><dt id='KzRwa'><q id='KzRwa'><span id='KzRwa'><b id='KzRwa'><form id='KzRwa'><ins id='KzRwa'></ins><ul id='KzRwa'></ul><sub id='KzRwa'></sub></form><legend id='KzRwa'></legend><bdo id='KzRwa'><pre id='KzRwa'><center id='KzRwa'></center></pre></bdo></b><th id='KzRwa'></th></span></q></dt></tr></i><div id='KzRwa'><tfoot id='KzRwa'></tfoot><dl id='KzRwa'><fieldset id='KzRwa'></fieldset></dl></div>

        <small id='KzRwa'></small><noframes id='KzRwa'>

        <tfoot id='KzRwa'></tfoot>

      2. 两个 div 用对角线分割 - CSS

        时间:2024-04-18
              <tbody id='FrMGv'></tbody>

          • <small id='FrMGv'></small><noframes id='FrMGv'>

            <legend id='FrMGv'><style id='FrMGv'><dir id='FrMGv'><q id='FrMGv'></q></dir></style></legend>
              • <bdo id='FrMGv'></bdo><ul id='FrMGv'></ul>

                  <tfoot id='FrMGv'></tfoot>
                  <i id='FrMGv'><tr id='FrMGv'><dt id='FrMGv'><q id='FrMGv'><span id='FrMGv'><b id='FrMGv'><form id='FrMGv'><ins id='FrMGv'></ins><ul id='FrMGv'></ul><sub id='FrMGv'></sub></form><legend id='FrMGv'></legend><bdo id='FrMGv'><pre id='FrMGv'><center id='FrMGv'></center></pre></bdo></b><th id='FrMGv'></th></span></q></dt></tr></i><div id='FrMGv'><tfoot id='FrMGv'></tfoot><dl id='FrMGv'><fieldset id='FrMGv'></fieldset></dl></div>
                  本文介绍了两个 div 用对角线分割 - CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图让两个 div 适合页面的整个宽度,但用对角线分成两半.

                  I am trying to get two divs to fit the full width of the page but split in half with a diagonal line.

                  如何通过 CSS 使用两个 div 来实现这一点?这是一个滑块,完成后需要将内容添加到每个部分

                  How can I achieve this with two divs through CSS? it is for a slider and needs content added to each part when finished

                  推荐答案

                  可以是这样的

                  示例 1

                  div {
                      min-height: 100px;
                      background: #D25A1E;
                      position: relative;
                      width: calc(50% - 30px);
                  }
                  .div1 {
                      float: left;
                  }
                  .div2 {
                      float: right;
                  }
                  .div1:after, .div2:before {
                      content:'';
                      position: absolute;
                      top: 0;
                      width: 0;
                      height: 0;
                  }
                  .div1:after {
                      left: 100%;
                      border-top: 100px solid #D25A1E;
                      border-right: 50px solid transparent;
                  }
                  .div2:before {
                      right: 100%;
                      border-bottom: 100px solid #D25A1E;
                      border-left: 50px solid transparent;
                  }

                  <div class="div1"></div>
                  <div class="div2"></div>

                  小提琴

                  示例 2

                  div {  
                      background: #D25A1E;
                      min-height: 100px;
                      width: calc(50% - 25px);
                      position: relative;     
                  }
                  .div1 {
                      float: left;
                  }
                  .div2 {
                      float: right;
                  }
                  div:after {
                      position: absolute; top: 0px;
                      content:'';    
                      z-index: -1;
                      height: 100%;
                      width: 50%;
                      background: #D25A1E;
                  }
                  .div1:after {    
                      right: 0;
                      transform-origin: bottom right;
                      transform: skewX(-20deg);
                  }
                  .div2:after {    
                      left: 0;
                      transform-origin: top left;
                      transform: skewX(-20deg);
                  }

                  <div class="div1"></div>
                  <div class="div2"></div>

                  小提琴

                  示例 3

                  * {
                    padding: 0;
                    margin: 0;
                    box-sizing: border-box;
                  }
                  
                  .blocks {
                    display: flex;
                    padding: 1em;
                  }
                  
                  .block {
                    background-color: #D25A1E;
                    min-height: 100px;
                    width: 50%;
                    width: calc(50% + 2rem);
                  }
                  
                  .block--left {
                    clip-path: polygon(0 0, 100% 0, calc(100% - 3rem) 100%, 0% 100%);
                  }
                  
                  .block--right {
                    margin-left: -2rem;
                    clip-path: polygon(3rem 0, 100% 0, 100% 100%, 0% 100%);
                  }

                  <div class="blocks">
                    <div class="block block--left"></div>
                    <div class="block block--right"></div>
                  </div>

                  这篇关于两个 div 用对角线分割 - CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:是否有使用非等分值的 jquery 滑块的插件或示例? 下一篇:带有中间点标记的范围输入(滑块)

                  相关文章

                    <bdo id='1HARG'></bdo><ul id='1HARG'></ul>
                1. <legend id='1HARG'><style id='1HARG'><dir id='1HARG'><q id='1HARG'></q></dir></style></legend>
                  <i id='1HARG'><tr id='1HARG'><dt id='1HARG'><q id='1HARG'><span id='1HARG'><b id='1HARG'><form id='1HARG'><ins id='1HARG'></ins><ul id='1HARG'></ul><sub id='1HARG'></sub></form><legend id='1HARG'></legend><bdo id='1HARG'><pre id='1HARG'><center id='1HARG'></center></pre></bdo></b><th id='1HARG'></th></span></q></dt></tr></i><div id='1HARG'><tfoot id='1HARG'></tfoot><dl id='1HARG'><fieldset id='1HARG'></fieldset></dl></div>

                  1. <tfoot id='1HARG'></tfoot>

                      <small id='1HARG'></small><noframes id='1HARG'>