如何使用CSS绘制移动设备边缘?

时间:2016-01-22 17:24:56

标签: html css

我对CSS很陌生,需要一些帮助才能使用CSS制作移动优势。

我们如何使用CSS绘制移动设备边缘?这是我尝试但无法做到的。

*,
*:after,
*:before {
  box-sizing: border-box;
}
.mobile {
  background: #E0E0E0;
  background-image: -webkit-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -moz-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -ms-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -o-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: linear-gradient(to bottom, #E0E0E0, #AEAEAE);
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 9px;
  text-shadow: 0px 0.5px 0px #fff;
  font-family: Courier New;
  color: #555555;
  width: 20%;
  height: 40%;
  font-size: 41px;
  padding: 10px 20px 10px 20px;
  border: solid #616161 1px;
  text-decoration: none;
  position: absolute;
  box-shadow: 0px 2px 2px #555555;
  margin: 1px;
  outline: #666666 solid 2px
}
.mobile:hover {
  text-decoration: none;
}
<div class="mobile"></div>

这应该是这样的:

enter image description here

我们该怎么做?

2 个答案:

答案 0 :(得分:1)

我会在您的box-shadow声明中加倍,而不是试图纠缠outline

box-shadow: 0px 0px 0px 1px #666666, 0px 2px 2px #555555;

*,
*:after,
*:before {
  box-sizing: border-box;
}
.mobile {
  background: #E0E0E0;
  background-image: -webkit-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -moz-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -ms-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -o-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: linear-gradient(to bottom, #E0E0E0, #AEAEAE);
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 9px;
  text-shadow: 0px 0.5px 0px #fff;
  font-family: Courier New;
  color: #555555;
  width: 20%;
  height: 40%;
  font-size: 41px;
  padding: 10px 20px 10px 20px;
  border: solid #616161 1px;
  text-decoration: none;
  position: absolute;
  box-shadow: 0px 0px 0px 1px #666666, 0px 2px 2px #555555;
  margin: 1px;
}
.mobile:hover {
  text-decoration: none;
}
<div class="mobile"></div>

0px 0px 0px 1px #666666语法给出阴影零模糊和1px偏移,基本上复制1px笔划。

答案 1 :(得分:0)

试试这个

*,
*:after,
*:before {
  box-sizing: border-box;
}
.mobile {
  background: #E0E0E0;
  background-image: -webkit-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -moz-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -ms-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: -o-linear-gradient(top, #E0E0E0, #AEAEAE);
  background-image: linear-gradient(to bottom, #E0E0E0, #AEAEAE);
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 9px;
  text-shadow: 0px 0.5px 0px #fff;
  font-family: Courier New;
  color: #555555;
  font-size: 41px;
  border: solid #616161 1px;
  text-decoration: none;
  box-shadow: 0px 1px #555555;
  margin: 1px;
  display: flex;
}
.mobile:hover {
  text-decoration: none;
}
<div style="width: 210px; height: 45px; border: solid #000 1px;" class="mobile">
  <div style="width: 210px; height: 45px; border: solid #fff 1px; " class="mobile">
    <div style="width: 200px; height: 40px;" class="mobile">
    </div>
  </div>
</div>