首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS div在缩小时缩小

CSS div在缩小时缩小
EN

Stack Overflow用户
提问于 2013-04-25 01:44:01
回答 1查看 1.6K关注 0票数 0

我使用div作为我站点的breadcrumbs。它在浏览器窗口的实际大小和放大时保持恒定大小。但在缩小时,div正在缩小。

这是我使用的代码。我是否需要在其中的某处进行编辑?

代码语言:javascript
复制
    <style>

.breadcrumb { 
        list-style: none; 
        overflow: hidden; 
        font: 18px Lucida Sans Unicode;
        text-align: center;
}
.breadcrumb li { 
        float: left;

}
.breadcrumb li a {
        color: white;
        text-decoration: none; 
        padding: 11px 0 11px 55px;
        background:  #327ea4;                   /* fallback color */
        background:  #327ea4; 
        position: relative; 
        display: block;
        float: left;
        width: 15.12em;
        /*width: 15.1185em;*/
        cursor: default;
        border-top-left-radius: .4em;
        pointer-events: none;
}
.breadcrumb li a:after { 
        content: " "; 
        display: block; 
        width: 0; 
        height: 0;
        border-top: 50px solid transparent;           /* Go big on the size, and let overflow hide */
        border-bottom: 50px solid transparent;
        border-left: 30px solid  #327ea4;
        position: absolute;
        top: 50%;
        margin-top: -50px; 
        left: 100%;
        z-index: 2; 
}   
.breadcrumb li a:before { 
        content: " "; 
        display: block; 
        width: 0; 
        height: 0;
        border-top: 50px solid transparent;           /* Go big on the size, and let overflow hide */
        border-bottom: 50px solid transparent;
        border-left: 30px solid white;
        position: absolute;
        top: 50%;
        margin-top: -50px; 
        margin-left: 1px;
        left: 100%;
        z-index: 1; 
}   
.breadcrumb li:first-child a {
        padding-left: 30px;
}
.breadcrumb li:nth-child(2) a       { background:        #7fc1ec; color: #327ea4; cursor: default;}
.breadcrumb li:nth-child(2) a:after { border-left-color: #7fc1ec; color: #327ea4; cursor: default;}
.breadcrumb li:nth-child(3) a       { background:        #7fc1ec; color: #327ea4; cursor: default;}
.breadcrumb li:nth-child(3) a:after { border-left-color: #7fc1ec; color: #327ea4; cursor: default;}
.breadcrumb li:nth-child(4) a       { background:        #7fc1ec; color: #327ea4; cursor: default;}
.breadcrumb li:nth-child(4) a:after { border-left-color: #7fc1ec; color: #327ea4; cursor: default; }
.breadcrumb li:last-child a {
        /*background: white !important;*/
        /*color: black;*/
        pointer-events: none;
        cursor: default;
        border-top-right-radius: .4em;
}
.breadcrumb li:last-child a:after { border: 0; }
    </style>

<div style="width:75em;" oncontextmenu="return false"  >
    <ul class="breadcrumb">
        <li><a href="#">Step 1</a></li>
        <li><a href="#">Step 2</a></li>
        <li><a href="#">Step 3</a></li>
                    <li><a href="#">Step 4</a></li>
    </ul>

</div>

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-04-25 01:55:40

当您在EM中定义元素的高度或宽度时,如以下代码片段所示...

代码语言:javascript
复制
.breadcrumb li a {
        color: white;
        text-decoration: none; 
        padding: 11px 0 11px 55px;
        background:  #327ea4;
        background:  #327ea4; 
        position: relative; 
        display: block;
        float: left;
        width: 15.12em; /* <-- RIGHT HERE */
        cursor: default;
        border-top-left-radius: .4em;
        pointer-events: none;
}

..。您实际上是将元素的大小绑定到该元素的字体大小。

当你增加浏览器的“缩放”时,所有发生的都是字体大小的增加(以像素为单位)。

示例:

font-size: 10px,因此width: 2em == width: 20px

缩放(增加字体大小)

font-size: 12px,因此width: 2em == width: 24px

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16198766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档