html - 如何将内部div放入外部div

标签 html css

HTML:

<div style="width: 300px; position: absolute; right: 25%; top: 5%; -webkit-box-shadow: 2px 4px 40px 0px rgba(0,0,0,0.75); -moz-box-shadow: 2px 4px 40px 0px rgba(0,0,0,0.75);box-shadow: 2px 4px 40px 0px rgba(0,0,0,0.75);">
    <section class="notif notif-warn">
        <h6 class="notif-title">Warning!</h6>
        <p>This task was forced checked out by another user. Your changes will not be saved Site.Master.</p>
        <div class="notif-controls">
            <a href="#" class="notif-close" id="cBtn">Close</a>
        </div>
    </section>
</div>

JSFIDDLE:http://jsfiddle.net/sikni8/kb2r6d4c/1/

如何更新我的 CSS 以确保内部 DIV 适合具有框阴影的外部 DIV。

最佳答案

您可以将 box-sizing: border-box; 添加到您的 .notif 类或删除 100% 宽度。

问题是,当您向元素添加 100% 宽度 + 填充时,它会导致溢出。

关于html - 如何将内部div放入外部div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29948430/

相关文章:

html - 在顶部为 <li> 中的事件链接添加一个 bg-image,可能吗?

html - 如何在标准 html 中显示文本

javascript - 如何应用我的 React 样式与三元运算符内联?

html - 如何让3个div填满父容器的高度

ASP.NET:设置 Label 控件的样式时出现奇怪的输出

jQuery .css 增加了 html() 的长度

html - 如何创建简单的水平时间轴

jquery - 返回低不透明度 div 中内容的不透明度

jquery - 图像 block 问题内的图像比例

javascript - 如何解析其中包含 "@"的 JSON 路径?