简体   繁体   English

HTML Bootstrap将图像放入行中的一列

[英]HTML Bootstrap placing an image into a column within row

I am using a container with a row construct to make a header. 我正在使用带有行构造的容器制作标题。 I would like for the leftmost column to have an image. 我想要最左边的一列有一个图像。 However, whenever I add an image it gets added full sized. 但是,每当我添加图像时,它都会添加完整尺寸。 I would like it to be limited to the set size of that column. 我希望将其限制为该列的设置大小。

This is my current HTML code: 这是我当前的HTML代码:

 .logo { max-width: 100%; max-height: 100%; } 
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="jumbotron" > <div class="container"> <div class="row"> <div class="col-xs-1"> <div class="image-container"> <center> <img src="https://i.pinimg.com/originals/fb/76/5b/fb765b8752d50de50cfa15203f9a7acd.png" alt="test" class="logo"> </center> </div> </div> <div class="col-xs-10"> <h2><center>TEST HEADER</center></h2> <h4><center>TEST SUBTEXT</center></h4> </div> <div class="col-xs-1"> <center>wowow</center> </div> </div> </div> </div> 

I tried adding the in my CSS file but it did not change anything. 我尝试在CSS文件中添加,但没有任何改变。

How can I have it such that the image follows the set size of the container? 如何使图像遵循容器的设置大小?

尝试添加以下CSS:

.image-container .logo{ width:100%; }

The image is taking the full size of the col-xs-1 column. 该图像采用col-xs-1列的完整大小。 Just it is taking padding from left and right which all col- classes have. 只是从左到右填充所有类。

If you want to make image a little bigger, then define its height (or width any one ) in px. 如果要使图像更大一点,则以px为单位定义其高度(或宽度)。

like the below: 如下所示:

.image-container .logo {
width: 100px;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM