html - 将网页背景拆分为不同的区域,以获得不同的颜色、图案等

标签 html css

在我的网站上,我试图将背景分成不同的区域。 An area with just a solid black background and an area that will have a repeating background, this can be seen in the image attached.我试图使两侧的图案区域水平和垂直延伸,当然,它到达可视网页的末尾。

对我来说,这似乎是一个特别棘手的概念,我想过在两边使用部分,但我只是习惯于相对定位元素,我希望它是精确的。我还考虑过进入 Photoshop 创建一个过宽过高的图案,然后以这种方式覆盖整个区域。

这些似乎都不是最佳解决方案。

关于我应该如何设置它,您有什么建议吗?

最佳答案

你可以按照这个:

.main-container {
    width: 100%;
    text-align: center;
    background-image: url(http://abduzeedo.com/sites/default/files/originals/pattern-library.jpg);
}
.sub-container {
    display: inline-block;
    margin: 0 auto;
    padding: 0 200px;
    background-color: black;
}
.content-block {
    background-color: white;
    width: 600px;  //You can add your width here like 1024px 
    margin: 0 auto;
    padding: 20px 15px;
}
<div class="main-container">
    <div class="sub-container">
        <div class="content-block">
            <h1>Add your content here</h1>
            <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        </div>
    </div>
</div>

关于html - 将网页背景拆分为不同的区域,以获得不同的颜色、图案等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48576010/

相关文章:

javascript - 带参数的jQuery淡入淡出函数

javascript - 检测按键文件

javascript - React Native Animated - 以按下为中心展开圆圈

javascript - AngularJS SEO 使用 HTML5 模式 : Would love some clarity on how this functions behind-the-scenes

css - 将图像或 <h2> 向下推一点

javascript - 元素 JQuery 的祖 parent 的第一个 child

html - CSS 粘性 header

html - 如何删除 Chrome 中选择框的背景(在 iOS 上)

css - 列出每页的菜单下划线

html - CSS 库(例如 :Bootstrap) that supports IE6?