Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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和CSS-容器中的内联图像(白色背景)_Html_Css - Fatal编程技术网

html和CSS-容器中的内联图像(白色背景)

html和CSS-容器中的内联图像(白色背景),html,css,Html,Css,我希望我的内联图像在一个容器中(白色背景)。我的html是: <div class="row"> <div class="col-md-12"> <div class="award-select"> <div class="image-group"> <img class="myimg" alt="B

我希望我的内联图像在一个容器中(白色背景)。我的html是:

<div class="row">
            <div class="col-md-12">
                <div class="award-select">
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                </div>
            </div>
        </div> <!-- /row -->
当我加上:

.image-group {
    width: 130px;
    height: auto;
    float: left
  }
为了让我的图像内联,我松开了白色背景。

问题是“.image group”div被设置为
float
,而float div没有任何尺寸。所以你的“.award select”div是0px乘以0px

解决方案1: 您只需添加
高度:100%到您的“.奖励选择”部门

。奖励选择{
最大宽度:100%;
左侧填充:10px;
背景色:红色;
边框:1px实心#e5;
-webkit边界半径:5px;
-moz边界半径:5px;
边界半径:5px;
-webkit盒阴影:0 1px2pRGBA(0,0,0,05);
-moz盒阴影:0 1px2pRGBA(0,0,0,05);
盒影:0 1px2pRGBA(0,0,0,05);
身高:100%;
}
.图像组{
宽度:130px;
高度:自动;
浮动:左
}

日期
日期
问题在于“.image group”div被设置为
float
,并且浮动div没有任何维度。所以你的“.award select”div是0px乘以0px

解决方案1: 您只需添加
高度:100%到您的“.奖励选择”部门

。奖励选择{
最大宽度:100%;
左侧填充:10px;
背景色:红色;
边框:1px实心#e5;
-webkit边界半径:5px;
-moz边界半径:5px;
边界半径:5px;
-webkit盒阴影:0 1px2pRGBA(0,0,0,05);
-moz盒阴影:0 1px2pRGBA(0,0,0,05);
盒影:0 1px2pRGBA(0,0,0,05);
身高:100%;
}
.图像组{
宽度:130px;
高度:自动;
浮动:左
}

日期
日期

使用此代码,添加class=“clearfix”以清除浮动问题

<div class="award-select">
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                    <div class="clearfix"></div>
                </div>

日期
日期

使用此代码,添加class=“clearfix”以清除浮动问题

<div class="award-select">
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                    <div class="image-group">
                        <img class="myimg" alt="Bootstrap Image Preview" src="images/wosmmop.png" />
                        <figcaption>Date</figcaption>
                    </div>
                    <div class="clearfix"></div>
                </div>

日期
日期

在奖励选择类中添加浮动或高度

.award-select{float:left}
.award-select{height:200px;}

你的背景一直在关闭,因为奖励选择类上没有浮动,但你的另一个类上有一个浮动,你需要浮动才能同时在这两个类上。添加高度也可以解决问题。

为您的奖励选择类添加浮动或高度

.award-select{float:left}
.award-select{height:200px;}

你的背景一直在关闭,因为奖励选择类上没有浮动,但你的另一个类上有一个浮动,你需要浮动才能同时在这两个类上。增加高度也可以解决这个问题。

我调整了你的
CSS

下面是代码(运行底部的代码段):

。奖励选择
{
位置:相对位置;
浮动:左;
最大宽度:100%;
左侧填充:10px;
背景色:#fff;
边框:1px实心#e5;
-webkit边界半径:5px;
-moz边界半径:5px;
边界半径:5px;
-webkit盒阴影:0 1px2pRGBA(0,0,0,05);
-莫兹盒阴影:0 1px2pRGBA(0,0,0,05);
盒影:0 1px2pRGBA(0,0,0,05);
}
.图像组
{
位置:相对位置;
浮动:左;
宽度:130px;
高度:自动;
背景:透明;
}

日期
日期

我调整了你的
CSS

下面是代码(运行底部的代码段):

。奖励选择
{
位置:相对位置;
浮动:左;
最大宽度:100%;
左侧填充:10px;
背景色:#fff;
边框:1px实心#e5;
-webkit边界半径:5px;
-moz边界半径:5px;
边界半径:5px;
-webkit盒阴影:0 1px2pRGBA(0,0,0,05);
-莫兹盒阴影:0 1px2pRGBA(0,0,0,05);
盒影:0 1px2pRGBA(0,0,0,05);
}
.图像组
{
位置:相对位置;
浮动:左;
宽度:130px;
高度:自动;
背景:透明;
}

日期
日期