0

我有一个样式复选框,我想在标签旁边有一个链接。标签有不同的宽度,所以我不能把链接放在左边。由于样式复选框,我无法使用 css“检测”标签的宽度。因此,为了清楚起见,在我所做的 jsfiddle 中,我希望链接信息位于标签的左侧。

http://jsfiddle.net/SAZ2P/3/

干杯!

CSS:

.selectbox {
    position: relative;
    display: inline-block;
}

.selectbox input[type="checkbox"] {
    visibility: hidden;
}

.selectbox label {
    cursor: pointer;
    position: absolute;
    width: 15px;
    height: 15px;
    top: 0;
    background: #fcfff4;
    border: 1px solid #000;
    text-indent: 30px;
    white-space: nowrap;
    letter-spacing: 2px;
    line-height: 17px;
}

.selectbox label:after {
    opacity: 0;
    content: '';
    position: absolute;
    width: 6px;
    height: 4px;
    background: transparent;
    top: 2px;
    left: 3px;
    border: 2px solid #333;
    border-top: none;
    border-right: none;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

.selectbox label:hover::after {
    opacity: 0.5;
}

.selectbox input[type=checkbox]:checked + label:after {
    opacity: 1;
}

.selectbox a{
    float: left;
}
4

1 回答 1

1

我认为最好将链接包含在标签内。例如:

<div class="selectbox">
    <input type="checkbox" value="brand2" id="brand2" name="brand2" class="box">
    <label for="brand2"><a href="/link" id="brand_info">info</a> brand with longer name</label>
</div>
于 2013-03-14T22:04:23.893 回答