HTML/CSS 标签 : Labels taking on the properties of other labels

标签 html css checkbox tabs

我很好奇是否有一种简单的方法可以使标签采用 CSS 样式属性的默认值。我的复选框采用了我的选项卡的属性,我只希望它们成为默认值。正如您将看到的,我更改了复选框的字体大小,使其小于选项卡。但是,我不想仅仅为了取消选项卡的样式而编写 CSS。我知道我缺少一些东西。谢谢。

enter image description here

标签的 CSS:

           .tabs label {
            box-shadow: 0px 4px 10px #888888;
            display: block;
            padding: 10px 20px;
            border-radius: 2px 2px 0 0;
            color: #207cca;
            font-size: 20px;
            font-weight: normal;
            font-family: Impact, Verdana, sans-serif;
            background: rgba(255,255,255,0.2);
            cursor: pointer;
            position: relative;
            -webkit-transition: all 0.5s ease-in-out;
            -moz-transition: all 0.5s ease-in-out;
            -o-transition: all 0.5s ease-in-out;
            transition: all 0.5s ease-in-out;
        }

复选框的 CSS:

            #sidebar label {
            font-size: 10px;

        }

HTML 标签:

    <ul class="tabs">
         <li>
            <input type="radio" checked name="tabs" id="tab1">
            <label for="tab1">Resource Browser</label>
            <div id="tab-content1" class="tab-content animated fadeIn">

HTML 复选框:

    <div id="sidebar" class="sidebar">
                <form action="/result/" method="get">
                    <p> Demographics </p>
                    <input type="checkbox" name="male" value="selected" id="g_male" />
                    <label for="g_male">male</label><br>
                    <input type="checkbox" name="female" value="selected" id="g_female" />
                    <label for="g_female">female</label><br>
                    <input type="checkbox" name="age1-3" value="selected" id="age1-3" />
                    <label for="age1-3">Age 1-3</label><br>
                    <input type="checkbox" name="age3-18" value="selected" id="age3-18" />
                    <label for="age3-18">Age 3-18</label><br>
                    <input type="checkbox" name="age18+" value="selected" id="age18+" />
                    <label for="age18+">Age 18+</label><br>

最佳答案

您可以通过以下方式直接定位标签:

.tabs > li > label {
    /* CSS here... */
}

#sidebar > form > label { 
    /* CSS here... */ 
}

关于HTML/CSS 标签 : Labels taking on the properties of other labels,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29400385/

相关文章:

javascript - 使用 HTML5 Canvas 或 Javascript 的 Pushlet

html - Bootstrap 3,下拉问题

javascript - 多 div 的动画滚动顶部问题

标题中带有 "Select All"复选框的 Android MultiSelectListPreference

javascript - 使用 JavaScript 在网站上按下按钮

css - CSS中的 flex 、流体、液体、固定布局有什么区别

php - Silverstripe:在 Widget 安装时导入特定于 Widget 的 CSS

html - 有人可以帮我弄清楚为什么我的 ul 没有变成水平导航吗?谢谢 :)

javascript - 使用 Angular.js 在每一行中为数据表 jQuery 添加一个复选框

javascript - 使用 jQuery 获取表单提交上的复选框值并将其存储在变量中