html - 负 css 行未使用 100% svg 图像正确缩放

标签 html css svg

希望我能正确解释这一点。

请参阅随附的 fiddle 示例:http://jsfiddle.net/Ldd70cnd/

基本上,我有一个 100% 宽度的 svg 图像,然后我想添加 2 条彩色线,1 条在上方,1 条在下方,但我希望这些线位于 svg 的边界内,请参见图像。

Fist image 上面的示例显示了 svg 图像最边缘的线条。

Second image

上面的示例向您展示了我想要线条的位置,我的 jsfiddle 使顶线工作正常,如果您调整浏览器的大小,底线不会保持一致。

有人能帮忙吗?

这是我使用的 CSS。

.logo-top-line { 
    height:2px; 
    width:100%; 
    background : rgb(88, 168, 144);
    margin-top:3%;
}
img {
    width: 100%;
    margin-top:-2.6%;
}
.logo-bottom-line { 
    height:2px; 
    width:100%; 
    background : rgb(88, 168, 144);
    margin-top:-1em;
}

最佳答案

我相信这会给你你想要的:http://jsfiddle.net/Ldd70cnd/1/

这使用了一个带有position: relative 的容器并且所有的 child 都得到了position: absolute。然后根据容器边缘的相对位置定义顶线和底线。

HTML:

<div id="wrapper">
    <div class="logo-top-line"></div>
    <img src="http://s22.postimg.org/skt2j3581/logo2.png" alt=""/>
    <div class="logo-bottom-line"></div>
</div>
<div class="contact text">Mobile: 000000000000</div>

CSS:

* {
    margin:0;
    padding:0;
}
#wrapper {
    position: relative;
}
.logo-top-line { 
    height:2px; 
    width:100%; 
    background : rgb(88, 168, 144);
    position: absolute;
    top: 12.5%;
}
img {
    width: 100%;
}
.logo-bottom-line { 
    height:2px; 
    width:100%; 
    background : rgb(88, 168, 144);
    position: absolute;
    bottom: 11.5%;
}
.contact {
    font-family : Helvetica;
    font-size : 15px;
    line-height : 26.04px;
    color : rgb(31, 80, 108);
}

关于html - 负 css 行未使用 100% svg 图像正确缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29016127/

相关文章:

html - 如何使用 CSS 为所有浏览器垂直居中 div 元素?

javascript - 有没有办法用javascript计算svg元素的混合模式(css)?

SVG - 如何将图像裁剪为圆形?

javascript - 使用输入更新 html 表

html - 有使用 justinmind prototype 创建自定义 html/css 组件的原型(prototype)设计经验吗?

html - 使 "text-overflow: ellipsis"在表格单元格内工作 *无需* 设置 "table-layout:fixed"

html - 如何防止使用 CSS 对 DOM 上的特定单词组进行自动换行?

html - 在 apache trinidad 中覆盖元素样式

php - 不使用 ImageMagick 从 SVG XML 创建 PNG

javascript - ASP 控件在隐藏时丢失状态