html - 使用圆 Angular 时子 div 不填充父 div

标签 html css

根据标题,您可以看到问题的演示 here .

这是HTML代码:

<div id="outer">
    <div id="inner">
    </div>
</div>

这是CSS代码:

#inner{
  height: 100%;
  width: 100%;
    border-radius: 20px;
    text-shadow: 5px 5px 5px #000000;
    background-color: white;
    opacity: 0;
    -webkit-transition: opacity .5s linear;
    -moz-transition: opacity .5s linear;
    transition: opacity .5s linear;
}

#inner:hover{
    opacity: 1;
}

#outer{
    border: 6px solid #dcc5c5;
    border-radius: 20px;
    text-shadow: 5px 5px 5px #000000;
    position: relative;
    display: inline-block; 
    transition: all 0.5s ease-in-out;
    background-color: red;
  height: 200px;
  width: 200px;
}

我尝试了各种建议 herehere没有解决方案。

最佳答案

您正在使用 ma​​rgin-top:20px; 在这个元素中

#inner {
    height: 100px;

    background-color: #42749F;
    width: 200px;

    /* -1px here for to compansate for the outer border of the container */
    -moz-border-radius: 0 0 9px 9px;
}

移除边距,它将填充到父元素中

Working fiddle

关于html - 使用圆 Angular 时子 div 不填充父 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46776434/

相关文章:

CSS:灵活的盒子越过元素的边缘

html - 如何在另一个 div 中正确添加 div,这样原始设计就不会中断?

javascript - 我想随机显示 div - 我该怎么做?

html - 将样式应用于元素

javascript - 更改标签值

css - 字体大小 : EMs vs Pixels. .. 在 2011 年,应该使用哪一个?

javascript - 多行系列中鼠标悬停的问题

html - 我的 Bootstrap 轮播不工作

css - 一列高的 Bootstrap (或一般的 CSS)

css - CSS 级联是否根据您将类添加到 HTML 元素的顺序来应用重要性?