html - CSS:剪刀式图像布局

标签 html css responsive-design

这是PNG,使用PS:

Scissor-Cut

对于图像:Scissor Cut 2

看,它是一种梯形,一边垂直,另一边倾斜。

如何在 html/css 中制作此布局,以便将转发到此 div 的任何图像始终显示在梯形内,并创建此精美的 ui。

如何在 HTML/CSS 中创建这种形状? 接受答案后的代码:

<div class="scissor"><img src="1.png" style="width:200px"></div>

和CSS:

.scissor{       
    width: 300px;
    height: 150px;
    background: #FF6100;
    position: relative;
}
.scissor:after{
    content: '';
    position: absolute; top: 100%; left: 0;
    width: 0;
    height: 0;
    border-top: 100px solid #000; 
    border-right: 300px solid transparent;  
    display: block; 

}
span{
    display: inline-block;
    width: 80px;
    height: 80px;
    border: 10px solid #fff;
    border-radius: 50%;
    position: absolute; top: 40%; left: 50%;
    z-index: 1;
    transform: translateX(-50%);
}

最佳答案

使用伪元素 - :before:after

div{       
    width: 300px;
    height: 300px;
    background: #FF6100 url('http://www.hybworks.co.uk/wp-content/uploads/2015/05/los-angeles-auto-repair-300x300.jpg') no-repeat 0 0;
    position: relative;
}
div:after{
    content: '';
    position: absolute; bottom: 0px; left: 0;
    width: 0;
    height: 0;
    border-top: 150px solid transparent; 
    border-right: 300px solid #fff;  
    display: block; 
}
span{
    display: inline-block;
    width: 120px;
    height: 120px;
    text-align: center;
    line-height: 120px;
    font-size: 60px;
    font-family: 'segoe ui';
    color: #fff;
    border: 10px solid #fff;
    border-radius: 50%;
    position: absolute; top: 10%; left: 50%;
    z-index: 1;
    transform: translateX(-50%);
}
<div>
    <span>D</span>
</div>

示例 2 - 使用 svg

<svg width="300" height="200">
  <polyline points="10, 10 300, 10 300, 100 10, 200 10, 100 10, 10" stroke-width="1" stroke="rgb(255,97,0)" fill="rgb(255,97,0)">
</svg>

关于html - CSS:剪刀式图像布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31054898/

相关文章:

html - 响应式视频的最大高度

css - 如何删除导航栏切换菜单折叠和标题之间的空间

javascript - 将用户输入传递给 Javascript 变量以更改 api 结果

html - Css 显示无

html - 如何使中间div的宽度响应

css - float 和居中的 Wordpress 页面内容

html - Foundation - 根据 Foundation 断点重新组织 block

javascript - 如果文本值不起作用,请从按钮中删除禁用的属性

javascript - CSS 文本设置

css - 不要在布局复杂的 CSS Flex 框中拉伸(stretch)一个元素