Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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 如何在it上显示标题图像';它是全高的,而不在里面添加填充物吗?_Html_Css_Image_Height_Background Image - Fatal编程技术网

Html 如何在it上显示标题图像';它是全高的,而不在里面添加填充物吗?

Html 如何在it上显示标题图像';它是全高的,而不在里面添加填充物吗?,html,css,image,height,background-image,Html,Css,Image,Height,Background Image,我举了一个例子: 我希望标题上的背景图像始终为照片高度的100%。我只是不知道如何做到这一点,而不增加一吨填充到H2的图像顶部。我想我的另一个问题是,无论在什么设备上,我如何使背景图像全屏显示 这就是我正在尝试的。任何帮助都将不胜感激 .heading { background: url("http://www.lexcenter.com.br/site/wp-content/themes/dt-nimble/images/backgrounds/header/art-header-m

我举了一个例子:

我希望标题上的背景图像始终为照片高度的100%。我只是不知道如何做到这一点,而不增加一吨填充到H2的图像顶部。我想我的另一个问题是,无论在什么设备上,我如何使背景图像全屏显示

这就是我正在尝试的。任何帮助都将不胜感激

.heading {
    background: url("http://www.lexcenter.com.br/site/wp-content/themes/dt-nimble/images/backgrounds/header/art-header-main/full/r_atr-header-main.jpg");
height: 100%;
/* background-size: cover; */
}

.heading h2 {
    padding: 50px;
    text-align: center;
    color: white;
}

尝试将你的航向设定为100vh

.height{
  width: 100%;
  height: 100vh;
  background-image: url('http://www.lexcenter.com.br/site/wp-content/themes/dt-nimble/images/backgrounds/header/art-header-main/full/r_atr-header-main.jpg');
}
你也可以再设计一些。我想这更像是你在想什么

body{
  margin: 0;
  padding: 0;
 }

.height {
  width: 100%;
  height: 100vh;
  background-image: url('https://images.pexels.com/photos/949097/pexels-photo-949097.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

要制作标题背景图像,请尝试下面的代码

.heading {
  background: url("http://www.lexcenter.com.br/site/wp-content/themes/dt-nimble/images/backgrounds/header/art-header-main/full/r_atr-header-main.jpg");
  background-size: container; /* background size will be equal to your content */
  background-position: 50%;
  background-repeat: no-repeat;
}

.heading h2 {
  padding: 50px;
  text-align: center;
  color: white;
  margin: 0; /* reset the default margin for header tags */
}
* {    /* reset all the default margins and padding */
  padding: 0;
  margin: 0;
}

.background-bg {
  width: 100%
  height: 100vh; /* height will be equal to viewport.*/
  background-image: url("background-image.jpg");
  background-size: cover;
  background-position: 50%;
}
对于背景图像全屏,无论它在什么设备上,请尝试下面的代码

.heading {
  background: url("http://www.lexcenter.com.br/site/wp-content/themes/dt-nimble/images/backgrounds/header/art-header-main/full/r_atr-header-main.jpg");
  background-size: container; /* background size will be equal to your content */
  background-position: 50%;
  background-repeat: no-repeat;
}

.heading h2 {
  padding: 50px;
  text-align: center;
  color: white;
  margin: 0; /* reset the default margin for header tags */
}
* {    /* reset all the default margins and padding */
  padding: 0;
  margin: 0;
}

.background-bg {
  width: 100%
  height: 100vh; /* height will be equal to viewport.*/
  background-image: url("background-image.jpg");
  background-size: cover;
  background-position: 50%;
}