Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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/35.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_Bootstrap 4 - Fatal编程技术网

Html 如何将引导容器设置为固定大小?

Html 如何将引导容器设置为固定大小?,html,css,bootstrap-4,Html,Css,Bootstrap 4,我用的是bootstrap4。这是我的html: <div class="sprite container d-inline-block bg-info rounded p-1"> <span class="sprite-span-level">Top-right text over image</span> <img class="sprite-img" src="someimage"> <span class="spri

我用的是bootstrap4。这是我的html:

<div class="sprite container d-inline-block bg-info rounded p-1">
   <span class="sprite-span-level">Top-right text over image</span>
   <img class="sprite-img" src="someimage">
   <span class="sprite-span-nickname">text under image</span>
</div>
最终结果如下所示:。
我想要的是将图像强制为特定大小,并相应地调整container div。如何做到这一点?

如果我正确理解您的问题,您希望将容器的宽度更改为特定大小,但将图像的大小保持为100%(这将尝试覆盖整个容器)

您只需指定容器的宽度,图像大小将根据容器大小而相应更改

.container {
   width: 300px;
}

编辑:没关系,它成功了。我写错了什么。谢谢
.container {
   width: 300px;
}