css曲线边界渲染奇怪

时间:2013-06-26 06:34:47

标签: css border css3

我正试图用DIV和css绘制一些逻辑门。我看起来大部分都很好但是中间门(OR)在Chrome中绘制边框的方式有些奇怪。曲线中有2个间隙。同样在所有浏览器中,我都检查了OR门的左凹曲线在末端变薄了。

jsfiddle

门的HTML

<div class="gate">
    <div class="outer">
        <div class="inner">
            <div class="andInA"></div>
            <div class="andInB"></div>
            <div class="andOutA"></div>
            <div class="andLeft"></div>
            <div class="andRight"></div>
        </div>
    </div>
</div>
<br />
<div class="gate">
    <div class="outer">
        <div class="inner">
            <div class="orLeft"></div>
            <div class="orBottomRight"></div>
            <div class="orTopRight"></div>
            <div class="orLeftCurve"></div>
            <div class="orInA"></div>
            <div class="orInB"></div>
            <div class="andOutA"></div>
        </div>
    </div>
</div>
<br />
<div class="gate">
    <div class="outer">
        <div class="inner">
            <div class="andInA"></div>
            <div class="andInB"></div>
            <div class="andOutA"></div>
            <div class="andLeft"></div>
            <div class="andRight"></div>
            <div class="nand"></div>
        </div>
    </div>
</div>

门的CSS

.gate {
    position: relative;
    width: 300px;
    height: 150px;
}
.outer {
    position: relative;
    padding: 0 28.6% 0 0;
    height: 100%;
}
.inner {
    position: relative;
    margin: 0 20% 0 20%;
    width: 100%;
    height: 100%;
}
.gate .andLeft {
    position: absolute;
    left: 0px;
    height: 97%;
    width: 45%;
    background-color: white;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    border-top: 2px solid black;
    border-bottom: 2px solid black;
    border-left: 2px solid black;
    border-right: 0px solid black;
}
.gate .andRight {
    position: absolute;
    right: 0px;
    height: 97%;
    width: 75%;
    background-color: white;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    border-top: 2px solid black;
    border-bottom: 2px solid black;
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 100% 100% 0%;
}
.gate .nand {
    position: absolute;
    top: 50%;
    right: 20%;
    margin-top: -4%;
    margin-right: -30%;
    width: 10%;
    height: 12%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    border: 2px solid black;
    background-color: white;
    border-radius: 100% 100% 100% 100%;
}
.gate .orLeft {
    position: absolute;
    left: 0px;
    height: 100%;
    width: 25%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 2px solid black;
    border-bottom: 2px solid black;
    border-left: 0px solid black;
    border-right: 0px solid black;
}
.gate .orLeftCurve {
    position: absolute;
    left: -25%;
    height: 100%;
    width: 50%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 0px solid black;
    border-bottom: 0px solid black;
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 50% 50% 0%;
}
.gate .orTopRight {
    position: absolute;
    top: 0%;
    right: 0px;
    height: 50%;
    width: 75%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 2px solid black;
    border-bottom: 0px solid black;
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 100% 0% 0%;
}
.gate .orBottomRight {
    position: absolute;
    top: 50%;
    right: 0px;
    height: 50%;
    width: 75%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 0px solid black;
    border-bottom: 2px solid black;
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 0% 100% 0%;
}

.gate .andInA {
    position: absolute;
    top: 25%;
    margin-left: -20%;
    width: 20%;
    height: 1px;
    border-top: 2px solid black;
}
.gate .andInB {
    position: absolute;
    top: 74%;
    margin-left: -20%;
    width: 20%;
    height: 1px;
    border-bottom: 2px solid black;
}
.gate .andOutA {
    position: absolute;
    top: 50%;
    right: 0px;
    margin-right: -20%;
    width: 20%;
    height: 1px;
    border-top: 2px solid black;
}

.gate .orInA {
    position: absolute;
    top: 25%;
    margin-left: -20%;
    width: 41.5%;
    height: 1px;
    border-top: 2px solid black;
}
.gate .orInB {
    position: absolute;
    top: 74%;
    margin-left: -20%;
    width: 41.5%;
    height: 1px;
    border-bottom: 2px solid black;
}

1 个答案:

答案 0 :(得分:1)

边框的宽度似乎有问题。如果你修改为1px(每边的边框顶部和边框底部),它在Chrome中看起来很不错。 Check it out

.gate .orTopRight {
    position: absolute;
    top: 0%;
    right: 0px;
    height: 50%;
    width: 75%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 1px solid black; // Modified to 1px
    border-bottom: 0px solid black;
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 100% 0% 0%;
}
.gate .orBottomRight {
    position: absolute;
    top: 50%;
    right: 0px;
    height: 50%;
    width: 75%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: white;
    border-top: 0px solid black;
    border-bottom: 1px solid black; // Modified to 1px
    border-left: 0px solid black;
    border-right: 2px solid black;
    border-radius: 0% 0% 100% 0%;
}