【问题标题】:How to create lower edge of div slanted using html and css?如何使用 html 和 css 创建倾斜的 div 的下边缘?
【发布时间】:2018-06-23 23:32:09
【问题描述】:

我创建了一个正常为矩形的 div,但我需要一个代码才能使 div 的下边缘倾斜,并且它下方的其他 div 也是如此(可能再次倾斜边缘)。任何帮助将不胜感激。 到目前为止,这是我的代码 sn-p:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Assignment</title>
<!-- Bootstrap Styling css-->
<style type="text/css">
 .container{
   width: 100%;
   padding-top: 25px;
   background-color: black;
   height: 300px;
  }

  #logo{
    background-color: #FFFFFF;
    float: left;
    border-radius: 20px;
  }

  #eduhead{
    /*padding-left: 40px;*/
    margin-left: 10px;
    color: #3C89AA;
    font-weight: bold;
  }

  #newref{
    color: white;
    font-size: medium;
    text-align: right;
    font-weight: lighter;
  }
   table{
     width: 100%;
   }
    #signup{
      color:#FFFFFF;
      border-style: solid;
      border-width: 2px;
      border-color: #3C89AA;
      border-radius: 5px;
   }  
 </style>

 </head>
 <body>
   <div class="container">
  <table>
  <tr>
   <th></th>
   <th id="eduhead"><img src="assets/Group 31.png" id ="logo" 
  alt="img">&emsp;ASSIGNMENT</th>
   <th><a href="" title="Blog" id="newref">Blog</a></th>
   <th><a href="" title="Packages" id="newref">Packages</a></th>
   <th><a href="" title="Login" id="newref">Login</a></th>
   <th><a href="" title="Sign Up" id="signup">Sign Up</a></th>
    </tr>
  </table>
  </div>

<!--Including all the JavaScript Files of bootstrap-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js">
</script>

<!--Bootstrap Scrit CDN-->

以上是我的代码,包括 Bootstrap 的所有 CDN。有什么建议吗?

【问题讨论】:

  • 你能更精确的输出你想要的结果吗
  • 我希望 div(结束边缘)向右上角倾斜。 @TemaniAfif
  • 可以分享截图吗?你也能让你的代码工作吗?
  • 是的,但是你能告诉我如何在这里分享屏幕截图吗?
  • 当您编辑问题时,您有一个按钮可以在顶部添加图像

标签: html css styling


【解决方案1】:

Here 您可以看到解决问题的不同方法。下面我放了一个例子,你可以调整精确的值。我希望这会有所帮助。

.slanted {
  position: relative;
  background: red;
  padding: 30px;
  box-sizing: border-box;
  clip-path: polygon(0 0,100% 0vw,100% 75%,0 100%)
}
<div class="slanted">
  Content.
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-07
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 2017-11-26
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多