html - 如何将边框半径添加到 css 网格元素

标签 html css css-grid

enter image description here https://codepen.io/siddagra/pen/vYBoJyM 我想为五个紫色+灰色框的每一个添加边框半径,理想情况下不添加任何 html 样式,因为框本身内的 div 元素的排列可能会发生变化。请帮忙,我试过了:第一个 child 和第二个 child 选择器,但那没有用。

.ExpandedSetPiece:first-child {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.ExpandedSetPiece:last-child {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

最佳答案

试试这个:

.ExpandedSetPiece div:first-child {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.ExpandedSetPiece div:last-child {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

“ child ”一词可能有点误导。如果您在 .ExpandedSetPiece 上使用 :first-child,则表示这些组中的第一个。

关于html - 如何将边框半径添加到 css 网格元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58199457/

相关文章:

设计不均匀的 HTML 列表导航问题

html - 在 CSS 中居中内容同时支持 IE 和 chrome

CSS 网格最小内容单元格基于邻居扩展

javascript - (JS) 如何删除动态创建的最后一个元素?

javascript - 动态服务 - apache - 仅限 html、javascript 和 .htaccess

html - 理解盒子模型

html - 将屏幕拆分为网格并相对垂直和水平对齐元素

javascript - Bootstrap 按钮底部边框宽度为百分比

javascript - JQuery 忽略隐藏 div 中的元素值

html - 背景图像在较小的屏幕尺寸上不缩放