简体   繁体   English

如何使用 CSS / Bootstrap 3 制作斜线

[英]How to make Oblique lines with CSS / Bootstrap 3

How can I make a page like this with slanted lines?我怎样才能用斜线制作这样的页面?

在此处输入图片说明

Can I put an angle of 20 degrees for example?例如,我可以将角度设为 20 度吗? I have to put 3 div?我必须放3个div?

For now I put a first div to put a logo in the middle, then I put the navigation bar and I would like the navigation bar to be aligned with the angle just above the oblique line.现在我把第一个 div 放在中间一个标志,然后我把导航栏和我希望导航栏与斜线上方的角度对齐。 I have to work on bootstrap 3 I'm a bit lost.我必须在引导程序 3 上工作,我有点迷茫。 thank you very much for your help and explanations非常感谢您的帮助和解释

<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>

Either you can create div with clip-path I would recommand to use: https://bennettfeely.com/clippy/您可以使用我建议使用的clip-path创建 div: https : //bennettfeely.com/clippy/

Either you use background with linear-gradient.要么使用带有线性渐变的背景。

DEMO with clip-path:带剪辑路径的演示:

 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>

 .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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM