<分区>
<分区>
如何在 CSS 中创建十字?我只需要一个宽度为 1 像素、高度为 20 像素的十字。我试过这个问题“Create a cross shape in CSS”中的代码。但这对我来说太疯狂了,结果只有 1 行。
最佳答案
此代码应该为您完成:
<div class="cross"></div>
<style>
.cross {
height: 20px;
width: 20px;
position: relative;
//-webkit-transform: rotate(45deg); // this will make the cross an X
//-moz-transform: rotate(45deg); // this will make the cross an X
//transform: rotate(45deg); // this will make the cross an X
}
.cross:after, .cross:before {
position: absolute;
content: "";
background: red;
}
.cross:after {
top: 50%;
left: 0;
right: 0;
height: 1px;
}
.cross:before {
left: 50%;
top: 0;
bottom: 0;
width: 1px;
}
<style>
关于css - 如何在 CSS 中创建十字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32913588/
相关文章:
css - 如果 LESS 中存在特定类,则将变量设置为新值
css - 更少的延迟加载问题 - 使用 mixins 和变量在同一 css 文件中为 ltr 和 rtl 语言设置样式
html - 将类添加到 HTML 文本 (asp .net)
html - Div 在任何移动 safari 上都被拉伸(stretch)
javascript - 如果在 HTML 中引用了多个版本的 JS 文件(Bootstrap),哪个优先?
asp.net - Visual Studio : Handling Typescript and LESS project files (with TFS Build)