简体   繁体   English

如何设置这张图片的全角背景?

[英]How do I set a full width background like this picture?

在此处输入图片说明

There is a background image with 4 different colors as you see. 您会看到有4种不同颜色的背景图像。 I'm not sure how to turn this into HTML so that it covers the whole page (horizontally). 我不确定如何将其转换为HTML,以使其覆盖整个页面(水平)。 I have the following code: 我有以下代码:

 body{ background: url(http://uupload.ir/files/y7l4_bg.png) repeat-x; } .upper{ background: url(http://uupload.ir/files/ur8m_cloud.png); height:600px; } 
 <body> <!-- upper section --> <div class="upper"> This is the upper section </div> <!--end upper section--> </body> 

But clearly it doesn't work as expected. 但是很明显,它不能按预期工作。 What am I missing here? 我在这里想念什么?

 body{ background: url(http://uupload.ir/files/y7l4_bg.png) repeat-x; margin: 0; padding: 0; } .upper{ background: url(http://uupload.ir/files/ur8m_cloud.png); height:600px; background-repeat:no-repeat; background-position: center top; background-size: contain; } 
 <body> <!-- upper section --> <div class="upper"> This is the upper section </div> <!--end upper section--> </body> 

Quite simply the body isn't tall enough to show all of that image as the only thing in it is the upper div. 很简单,身体不够高,无法显示所有图像,因为其中唯一的东西就是上层div。

body {
    background: url(http://uupload.ir/files/y7l4_bg.png) repeat-x;
    height: 2513px; /* image height*/
}

See this fiddle 看到这个小提琴

Regardless, using a massive background image like that is probably not the optimum method, especially when that layout and presentaton could be simply achieved with minimal HTML & CSS. 无论如何,使用这样的大背景图像可能不是最佳方法,尤其是当可以使用最少的HTML和CSS来简单地实现布局和演示时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CSS-即使缩小网站格式后,如何使背景图片始终显示全角? - CSS - How do I make background picture always take full width even after making the format of the site smaller? 如何通过使用CSS扩展全宽图片,而不会影响图片的质量? - How do I make a full width picture extend, through using CSS, without effecting the quality of the picture? 如何获得可以拉伸到整个宽度的背景? - How do I get a background to stretch to the full width? 如何设置图片中的背景颜色 - how to set background color like in picture 如何设置此整页背景的html文档高度 - How do I set the html document height for this full page background 如何设置不同宽度的div之类的表格? - How do I set div like table with different width? 如何在幻灯片后面放置背景图片? (看起来像一个相框) - How do I put a background image behind my slideshow? (Will look like a picture frame) 如何在CSS中为页面的整个宽度和高度设置渐变背景? - how can I set my gradient background in css for full width and height of the page? 使用CSS,如何使图像作为背景图像跨越页面的整个宽度? - With CSS, how do I make an image span the full width of the page as a background image? 如何使用设置的高度和宽度值在 div 中将完整图像显示为背景 - How to show full image as background in div with set height and width values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM