css - 如何在 CSS 中创建十字?

标签 css less

<分区>

如何在 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/

上一篇:javascript - 类 ='col-md-12' 在 Firefox 中无法正常工作但在 Chrome 中工作?

下一篇:html - 在 Bootstrap 中设置缩进的 h4 元素的样式

相关文章:

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)

less - webpack 较少错误,它无法从 uikit 解析 .ttf 和 woff2 文件

javascript - 调整屏幕大小时如何使元素停止移动

html - 使用 CSS 使表格的顶部和底部边框可见

css - 我如何改变谷歌的 polymer 元素纸元素的大小?