html - 缩放时将背景图像和文字放在一起

标签 html image css

这是我的导航栏,由背景图片上的一些链接组成。我使用以下方法定位图像:

background-position: x% y%;

当我调整页面大小时或缩放页面时,图像和链接的位置会发生变化。正因为如此,链接会转到照片中的植被上,对比度使它们难以辨认。那么,有没有一种方法可以将链接和图像分组或保持在一起,以便将它们保持在我声明的位置 background-position: x% y%; 当我在100% 缩放?

enter image description here

最佳答案

我会弄清楚植被从左侧开始的位置,看起来大约是 10%。然后有这样的事情:

.background {
  background-position: left center;
  background-size: 100% auto;
}
.text-wrapper { /*Some wrapper around the header and links, alternatively you could use something like h1, a:first-child */
  margin-left: 10%; /* the value of this being the % that the vegetation starts */
}

关于html - 缩放时将背景图像和文字放在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19554542/

相关文章:

html - 当我将鼠标悬停在 div 标签外侧时,图标开始闪烁

html - 如何使段落的第二个元素缩进

android - Android WebView加载本 map 片的方法

html - 为什么样式没有应用到这个例子中的子元素?

html - CSS 菜单 - 导航栏在选择子项后拒绝突出显示父项

html - 如何使用::after 伪元素为单个样式设置两种字体颜色?

css - 两个div并排,右侧div固定宽度

image - 从输入图像获取RGB像素并在opencv中重建输出图像

html - 使所有图像大小相同

javascript - webview中的自定义文本选择颜色