html - CSS组合样式问题

标签 html css duplicates combinations

我有一个分为两部分的 div。左和右。 它开始为:

main-bottom-div-left{ 
    font-family: Arial;
    font-size: 25px;
    font-weight: bold;
    color: #5c5622;
    width:348px;
    margin-left:10px;
    padding-right:7px;
    margin-right:0px;
    margin-top:5px;
    height:30px;
    background-color:#d9d4a5;


    **float:left;**
}

main-bottom-div-right{ 
    font-family: Arial;
    font-size: 25px;
    font-weight: bold;
    color: #5c5622;
    width:348px;
    margin-left:10px;
    padding-right:7px;
    margin-right:0px;
    margin-top:5px;
    height:30px;
    background-color:#d9d4a5;


    **float:right;**
}

我在想如果有这样的东西会更有意义

main-bottom-div {
    font-family: Arial;
    font-size: 25px;
    font-weight: bold;
    color: #5c5622;
    width:348px;
    margin-left:10px;
    padding-right:7px;
    margin-right:0px;
    margin-top:5px;
    height:30px;
    background-color:#d9d4a5;
}

.left {
    float:left;
}


.right {
    float:right;
}

并以某种方式引用每个类似的东西

<div class="**main-bottom-div.right**"></div>
<div class="**main-bottom-div.left**"></div>

没有按预期工作,我也试过span。 我努力实现的目标是没有重复项,并且基本上拥有重复项。

最佳答案

您可以为一个元素分配多个类:

<div class="main-bottom-div right"></div>
<div class="main-bottom-div left"></div>

你只需要在它们之间留一个空格

关于html - CSS组合样式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6545846/

相关文章:

ios - SBJson 与 Facebook sdk iOS 冲突

java - 查找数组中相同的元素并防止重复计数

javascript - 从 HTML 页面运行 Javascript 游戏

html - 样式选择和多项选择?

javascript - 将 eventListener 添加到按钮以更改类 onmouseup/down

jquery - 如何淡出具有两个条件的元素 (.scrollTop > X && screen.width < 600)

mysql - 查找mysql查询的重复行

html - twitter bootstrap - 居中导航栏

jquery - href 为 "#",这是不好的做法吗?

html - 使用 CSS 将 3 个图像居中