html - 不影响容器的 float 图像

标签 html css

我需要在不影响 Div 容器的情况下将两个相似的图像 float 到部分容器的左侧和右侧。我需要它们在不影响红色框的位置或重叠的情况下占据绿色框的左侧和右侧。请帮忙。这是我的代码:

HTML:

<!Doctype html>
<html  lang="eng">
<head>
 <meta charset="utf-8">
 <title>Envy</title>
 <link rel="stylesheet" href="Envy.css">
</head>
<div id="M_wrap">
<body>

            <div id="F_head">
           <header id="M_head">Nhere</header> 
           <nav id="M_nav">
             <ul>

                 <li class="Esec"><a href="#">New in stock</a></li>
                 <li><a href="http://www.w3schools.com/css/css_padding.asp">Men</a></li>
                 <li><a href="#">Women</a></li>
                 <li><a href="#">Children</a></li>
                 <li><a href="#">Accessories</a></li>
             </ul>
           </nav>
           </div>
           <section id="M_section">
                <img class="SE1" src="Bg2.jpg">
                <img class="SE2" src="Bg2.jpg">
              <div id="S_wrap">

              </div>
           </section>


</body>
 </div>
</html>

CSS:

body{

}
#M_wrap{
background-size:cover;
width:70em;
margin:.8em auto;

}

#F_head{
width:100%;
margin:.2em auto;
}

#M_head{
color:#000000;
font: Italic bold 80px/50px "Times New Roman" Arial, Tamoha;
text-align:center;
text-shadow:2px 2px  #33ff00;
text-decoration:underline;

}
 #M_nav{
height:3em;
width:37.5em ;
margin:2em auto;
background-color:black; 
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
word-spacing:80px;
text-align:center;              
font:Italic bold 30px/20px Times "Times New Roman", tamoha;
}
#M_nav ul li{
display:inline;
}

li.Esec{
word-spacing:0px !important;
}


#M_nav li a {
display:inline-block;
padding: 0px 15px;
font-weight:bold;
border-right: 1px solid #ccc;
}
#M_nav a:link{
color:white;
font:Italic bold 30px/40px Times "Times New Roman", tamoha;
text-decoration:none;
}

#M_nav a:hover {
color:white;
text-shadow: 2px 2px black;
text-decoration:underline;
color:#33ff00 !important;
}

#M_nav a:active{
color:red;
}


#M_nav a:visited{
color:white;
text-shadow:2px 2px black;
}

#M_section{
margin:-3.75em 0 0 0;
width:100%;
height:50em;
border-style:solid;
border-color:#33ff00;
}

#S_wrap{
 margin:3em auto;
 width:80%;
 height:85%;
 position:center;
 border-style:solid;
 border-color:red;


}

最佳答案

东西 like this

这是我更改的部分 CSS:

.SE1 {
    float:left;
}
.SE2 {
    float:right;
}

#S_wrap{
    margin:0 auto 3em auto;
    /* didn't touch rest of rules you have for this ID */
}

关于html - 不影响容器的 float 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29062248/

相关文章:

javascript - 将动态 CSS 样式应用于谷歌地图的标记

javascript - 我的 html 文件不会链接到位于父目录中的样式表和 javascript

html - css水平导航错误

jquery - 如何阻止 anchor 链接跳转到页面的另一个区域

html - 使用 goquery 从网站检索文本

javascript - 我怎样才能将我的jquery变量值打印到div中,但是我在名为count的变量中得到了我的值

html - Flex basis 100% in column flexbox : full height in Firefox, not in Chrome

animation - CSS关键帧动画不起作用

html - 仅在特定元素内引用 CSS 类

css - 具有固定单元格宽度但自动表格宽度的表格