内部div在梯形形状的div中是不可见的

时间:2017-04-24 10:56:52

标签: html css html5 css3

我试图在梯形形状div中设置div。
但无论如何,内在的div是无形的。 我也试过z-indices。



.trapezoid
{
    border-color: transparent transparent rgba(255,0,0,0.2) transparent;
    border-width: 0px 10px 38px 10px;
    border-style: solid;
    height: 0;
    width: 40px;
    background-size: 430px;
    overflow: hidden;
    background-repeat: no-repeat;
    display: block;
    text-indent: -99999px;
    margin-top: 25px;
    margin-bottom: 25px;
    margin-left: 25px;
    margin-right: 25px;
    cursor: pointer;
}
.innerIcon
{
    width: 100%;
    height: 38px;
    border-radius: 16px;
    background-color: rgba(0,0,0,0.4);
}

<div class="trapezoid" title="Fire Range Down">
    	<!-- This inner div is invisible -->
	<div class="innerIcon"></div>
</div>
&#13;
&#13;
&#13;

请给我一些解决方案。

2 个答案:

答案 0 :(得分:5)

梯形刚刚边框组成,因此它没有高度(高度:在css中指定的0px)。因此overflow:hidden 导致问题被删除。将position:absolute设置为内部div ,将postion:relative设置为 trapezoid 即可。

  

以下是更新后的代码:

&#13;
&#13;
.trapezoid {
  border-color: transparent transparent rgba(255, 0, 0, 0.2) transparent;
  border-width: 0px 10px 38px 10px;
  border-style: solid;
  height: 0;
  width: 40px;
  background-size: 430px;
  /*overflow: hidden;*/
  background-repeat: no-repeat;
  display: block;
  text-indent: -99999px;
  margin-top: 25px;
  margin-bottom: 25px;
  margin-left: 25px;
  margin-right: 25px;
  cursor: pointer;
  /*New Css */
  position: relative;
}

.innerIcon {
  width: 100%;
  height: 38px;
  border-radius: 16px;
  background-color: rgba(0, 0, 0, 0.4);
  position: absolute;
  top: 0px;
}
&#13;
<div class="trapezoid" title="Fire Range Down">
  <!-- This inner div is invisible -->
  <div class="innerIcon"></div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

试试这个css

getShortDescription()