Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何设置大背景图像_Html_Css - Fatal编程技术网

Html 如何设置大背景图像

Html 如何设置大背景图像,html,css,Html,Css,我有一个PSD格式的设计,我正在将其转换为HTML/CSS。我想在后场设置一个大的图像,显示在头球后面。谁能告诉我怎么做 下面是一个例子: 正文{ 背景:url(“https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQxC6tuHBQvtvENnQRI-7iRaEfqigj-CUACU1EYXBMYD1J9VRJQ”); 背景尺寸:封面; 背景重复:无重复; } h1{ 颜色:#fff; 字体大小:30px; 文本对齐:居中; } 标题

我有一个PSD格式的设计,我正在将其转换为HTML/CSS。我想在后场设置一个大的图像,显示在头球后面。谁能告诉我怎么做

下面是一个例子:

正文{
背景:url(“https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQxC6tuHBQvtvENnQRI-7iRaEfqigj-CUACU1EYXBMYD1J9VRJQ”);
背景尺寸:封面;
背景重复:无重复;
}
h1{
颜色:#fff;
字体大小:30px;
文本对齐:居中;
}

标题
例如,如果它仅在
中,则需要添加以下CSS代码

header {
  background-image: url('path-to-image');
  background-position: relative; /* This depends on your preferences */
  background-size: cover;
}
如果在

HTML5不支持背景属性。改用CSS。使用CSS语法:
header img {
  position: relative;
  width: 100%;
  height: auto; /* or height: 100vh */
}