Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.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 如何在jumbotron中居中调整图像大小?_Html_Css_Bootstrap 4 - Fatal编程技术网

Html 如何在jumbotron中居中调整图像大小?

Html 如何在jumbotron中居中调整图像大小?,html,css,bootstrap-4,Html,Css,Bootstrap 4,我试图不只是居中我的图像,但也调整它的大小,因为它太大了。我希望我的图像像类似的网站一样位于导航栏的正上方。我怎样才能做到这一点 .jumbotron{ 文本对齐:居中; } .navbar-nav.navbar-center{ 位置:绝对位置; 左:50%; 转化:translatex(-50%); 字体大小:20px; } .navbar默认值{ 背景色:白色; 边框颜色:白色; } 您可以尝试使用此CSS将图像与您的jumbotron .jumbotron img{ w

我试图不只是居中我的图像,但也调整它的大小,因为它太大了。我希望我的图像像类似的网站一样位于导航栏的正上方。我怎样才能做到这一点

.jumbotron{
文本对齐:居中;
}
.navbar-nav.navbar-center{
位置:绝对位置;
左:50%;
转化:translatex(-50%);
字体大小:20px;
}
.navbar默认值{
背景色:白色;
边框颜色:白色;
}


您可以尝试使用此CSS将图像与您的
jumbotron

.jumbotron img{
  width:100%;
  height: auto
}

您可以尝试使用此CSS将图像与您的
jumbotron

.jumbotron img{
  width:100%;
  height: auto
}

由于您选择的图像的尺寸,因此没有完美的解决方案。如果您将此图像拉伸100%的宽度,仅拉伸jumbotron的高度,则图像将非常扭曲。假设您不希望图像高度拉伸整个屏幕,可以执行以下操作:

.jumbotron{
背景:url(https://images.unsplash.com/photo-1551308719-c0e80e6becc9?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=1950&q=80);
背景尺寸:封面;
背景位置:中心;
最小高度:400px;
}
.navbar-nav.navbar-center{
位置:绝对位置;
左:50%;
转化:translatex(-50%);
字体大小:20px;
}
.navbar默认值{
背景色:白色;
边框颜色:白色;
}


由于您选择的图像的尺寸,因此没有完美的解决方案。如果您将此图像拉伸100%的宽度,仅拉伸jumbotron的高度,则图像将非常扭曲。假设您不希望图像高度拉伸整个屏幕,可以执行以下操作:

.jumbotron{
背景:url(https://images.unsplash.com/photo-1551308719-c0e80e6becc9?ixlib=rb-1.2.1&ixid=eyjhcbfawqiojeymdd9&auto=format&fit=crop&w=1950&q=80);
背景尺寸:封面;
背景位置:中心;
最小高度:400px;
}
.navbar-nav.navbar-center{
位置:绝对位置;
左:50%;
转化:translatex(-50%);
字体大小:20px;
}
.navbar默认值{
背景色:白色;
边框颜色:白色;
}


您真的在使用Bootstrap 4吗?标记看起来像Bootstrap3。您真的在使用Bootstrap4吗?标记看起来像Bootstrap3。