盒子内 CSS 中的三角形

Triangle in CSS inside a box(盒子内 CSS 中的三角形)
本文介绍了盒子内 CSS 中的三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

嗯,我不知道如何正确解释.在这里,检查此屏幕截图,其中包含我想要制作的内容.我的设计师给了我这个.如果我找不到解决方案,我将使用图像而不使用代码.可以用 CSS3 做到这一点吗?

.

或此处的完整集成示例.

Well I don't know how to explain it correctly. Here, check this screenshot which has what I want to make. My designer gave me this. If I don't find a solution i'll use images and no code. Is it possible to do this with CSS3?

Here is the image

See the triangle inside that box? I want to do this. Thank you!

解决方案

Creative use of borders to achieve this effect, no images were harmed in the following sample and you can even set the position of the arrow on the element itself - becomes more straightforward if you can hardcode it for your design.

HTML

<div class="top">
    <span class="arrow" style="left:40%"></span>
</div>

CSS

.top {
    background:url(http://blog.positscience.com/wp-content/uploads/2013/08/ice-cream3.jpg);
    background-size:cover;
    width:300px;
    height:300px;
    border:1px solid #888;
    position:relative;
    overflow:hidden;
}
.arrow {
    border:30px solid #aaa;
    border-bottom:none;
    border-color:transparent #aaa transparent #aaa;
    position:absolute;
    left:0;
    bottom:0;
}
.arrow:before, .arrow:after {
    content:'';
    position:absolute;
    width:5000px;
    bottom:0;
    height:30px;
    background:#aaa;
}
.arrow:before {
    right:30px;
}
.arrow:after {
    left:30px;
}

Working JSfiddle sample.

Or the full integrated sample here.

这篇关于盒子内 CSS 中的三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to test @media print with protractor or selenium?(如何用量角器或硒测试@media print?)
Select OK button from N#39;th modal opened in testcafe(从 testcafe 中打开的第 N 个模式中选择 OK 按钮)
How to click a specified li for an autocomplete ul with Selenium IDE?(如何使用 Selenium IDE 为自动完成 ul 单击指定的 li?)
Test automation html element selectors. Element ID or DataAttribute(测试自动化 html 元素选择器.元素 ID 或 DataAttribute)
navigator.geolocation.getCurrentPosition not allowed on quot;file:///C:/quot; based access(“file:///C:/上不允许 navigator.geolocation.getCurrentPosition基于访问)
Geolocation not working on Safari 5.x on Windows 7/XP(地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用)