【问题标题】:How to make Oblique lines with CSS / Bootstrap 3如何使用 CSS / Bootstrap 3 制作斜线
【发布时间】:2020-10-14 22:09:03
【问题描述】:

如何制作这样的带有斜线的页面?

我可以设置一个 20 度的角度吗?我必须放3个div?

现在我把第一个 div 放在中间放一个标志,然后我放导航栏,我希望导航栏与斜线上方的角度对齐。 我必须在引导程序 3 上工作 我有点失落。非常感谢您的帮助和解释

<div class="container" style="background-color: #04342E; width:100%">
            <img class="img-responsive center-block" style="height: 600px; align-items: center;"; src="/i/gp-logo.png" />
 <nav class="navbar navbar-default" style="justify-content: space-between; background-color: transparent; background: transparent; border-color: transparent;">
                <ul class="nav navbar-nav" style="text-decoration: none">
                    <li class="nav-item">
                      <a class="nav-link active" href="#" style="color: white;">Accueil</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#" style="color: white;">Tableaux</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#" style="color: white;">Papeterie</a>
                    </li>
                     <li class="nav-item">
                      <a class="nav-link" href="#" style="color: white;">Book</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#" style="color: white;">A propos</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#" style="color: white;">Contact</a>
                    </li>
                </ul>
            </nav>
            <div>   
        </div> 
      </div>

【问题讨论】:

    标签: html css twitter-bootstrap-3


    【解决方案1】:

    您可以使用clip-path 创建 div 我建议使用:https://bennettfeely.com/clippy/

    您要么使用带有线性渐变的背景。

    带有剪辑路径的演示:

    body{
      background: #04342E;
      margin:0;
    }
    div.polygon{
      height: 100vh;
      width: 100vw;
      background: white;
      clip-path: polygon(0 25%, 100% 0, 100% 100%, 0 75%);
      
      display:flex;
    }
    
    .content{
      height: 50%;
      width: 100%;
      background-color:rgba(255,0,0,0.3); /** Just used to show the written area But it should be removed **/
      margin:auto;
    }
    <div class="polygon">
      <div class="content">
       Lorem ipsum
      </div>
    </div>

    【讨论】:

    • 非常感谢您的回答。这样,我可以在白色部分添加内容吗?
    • @Kimako 是的,你可以,我编辑了我的 sn-p 来告诉你你可以在哪里写(红色条),只需删除背景颜色。是的,你可以
    • 你太棒了!非常感谢,真的。
    【解决方案2】:

    .container {
      background-color: #04342E;
      width: 100%;
      height: 500px;
      position: relative;
    }
    
    .container::after {
      position: absolute;
      content: "";
      left: 0px;
      right: 0px;
      bottom: 0px;
      border-bottom: solid white 500px;
      transform-origin: bottom right;
      transform: skew(1000deg);
    }
    
    .container #content {
      background-color: #04342E;
      width: 100%;
      height: 500px;
      margin-top: 600px;
      position: relative;
    }
    
    .container #content::after {
      position: absolute;
      content: "";
      top: 0px;
      right: 0px;
      left: 0px;
      border-top: solid white 500px;
      transform-origin: top left;
      transform: skew(-1000deg);
    }
    <div class="container">
      <img class="img-responsive center-block" style="height: 100px; align-items: center;" ; src="./images/image 5.png" />
      <nav class="navbar navbar-default" style="justify-content: space-between; background-color: transparent; background: transparent; border-color: transparent;">
        <ul class="nav navbar-nav" style="text-decoration: none">
          <li class="nav-item">
            <a class="nav-link active" href="#" style="color: white;">Accueil</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" style="color: white;">Tableaux</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" style="color: white;">Papeterie</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" style="color: white;">Book</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" style="color: white;">A propos</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#" style="color: white;">Contact</a>
          </li>
        </ul>
      </nav>
      <div id="content">
      </div>
    </div>
    you can use psuedo classes in css to create this. see above for the code.
    

    【讨论】:

    • 它也有效,非常感谢您抽出宝贵时间。是否可以使菜单名称遵循斜线? (就在上面)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多