使用css的阴影的三角形

时间:2013-04-24 04:47:06

标签: html css

CSS

.caret-bottom
{
    display: inline-block;
    width: 0;
    height: 0;
    vertical-align:top;
    content: "";
    border-top: 9px solid #FFFFFF;
    border-right: 7px solid transparent;
    border-left: 7px solid transparent; 
    margin-top: 13px;
    margin-left: 4px;   
  }

HTML CODE

<div class="caret-left"></div>

我需要这个三角形的阴影底部,就像3D效果一样。

3 个答案:

答案 0 :(得分:1)

嗨帖子有点旧但有一个我用过的例子。 使用代码链接到demo

&#13;
&#13;
public class Proxy
{
    const string BaseUrl = "API url";
    const string ActionUrl = "API action url";

    string _jsonrequeststring; 

    public Proxy(string json)
    {
        _jsonrequeststring = json;
    }

    public Object Execute()
    {
        var client = new RestClient(BaseUrl); 
        var request = new RestRequest(ActionUrl); 

        request.RequestFormat = DataFormat.Json;
        request.AddBody(_jsonrequeststring);

        request.Method = Method.POST;
        var response = client.Execute(request);

        var content = response.Content;

        return content;
    }
}
&#13;
.triangle {
  position: relative;
  background-color: white;
  opacity: 0.7;
  text-align: left;
}
.triangle:before,
.triangle:after {
  content: '';
  position: absolute;
  background-color: inherit;
}
.triangle,
.triangle:before,
.triangle:after {
  width: 7em;
  height: 7em;
  border-top-right-radius: 30%;
}
.triangle {
  transform: rotate(-90deg) skewX(-30deg) scale(1, .866);
}
.triangle:before {
  transform: rotate(-135deg) skewX(-45deg) scale(1.414, .707) translate(0, -50%);
}
.triangle:after {
  transform: rotate(135deg) skewY(-45deg) scale(.707, 1.414) translate(50%);
}
.triangle {
  filter: drop-shadow(4px 7px 10px rgb(0, 0, 0));
  -webkit-filter: drop-shadow(4px 7px 10px rgb(0, 0, 0));
}
&#13;
&#13;
&#13;

答案 1 :(得分:0)

尝试这个,我认为它会帮助你

.caret-bottom {
  display: inline-block;
  width: 0;
  height: 0;
  content: "";
  border-top: 10px solid #fff;
  border-right: 10px solid transparent;
  border-left: 10px solid transparent;
  border-bottom: 10px solid transparent;
  position: relative;
}
.caret-bottom:before {
  width: 0;
  height: 0;
  content: "";
  border-top: 10px solid #000;
  border-right: 10px solid transparent;
  border-left: 10px solid transparent;
  border-bottom: 10px solid transparent;
  position: absolute;
  z-index: 1;
  top: -12px;
  left: -10px;
}
<div class="caret-bottom"></div>

答案 2 :(得分:0)

.triangle {
  width: 100px;
  height: 100px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 10px -17px rgba(0, 0, 0, 0.5);
}
.triangle:after {
  content: "";
  position: absolute;
  width: 50px;
  height: 50px;
  background: #999;
  -webkit-transform: rotate(45deg);
  top: 75px;
  left: 25px;
  box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5);
}
<div class="triangle"></div>

<强>样本

http://jsfiddle.net/w9Zgc/