[英]Float:Right images break out of div
I'm sure this has been answered before but I'm having trouble finding a solution. 我敢肯定这已经得到回答,但是我在寻找解决方案时遇到了麻烦。 This is what I currently have as my html: 这是我目前拥有的html:
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="flip">
<p>Click to slide the panel down or up</p>
<img class="ux" src="/path" alt="complete" height="32" width="32" align="right" />
<img class="ux" src="/path" alt="add" height="32" width="32" align="right" />
<img class="ux" src="/path" alt="edit" height="32" width="32" align="right" />
<img class="ux" src="/path" alt="remove" height="32" width="32" align="right" />
</div>
<div id="panel">Hello world!</div>
CSS: CSS:
body {
width: 80%;
margin: auto;
margin-top: 30px;
}
#panel,#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel
{
padding:50px;
display:none;
}
When I try to put these together, images appear on the bottom right side of the div border, and then alter further when the slideToggle()
is invoked. 当我尝试将它们放在一起时,图像会显示在div边框的右下角,然后在调用slideToggle()
时进一步更改。 My end goal is to have all 4 images inline with the paragraph tag. 我的最终目标是使所有4张图像都与段落标签内联。 Any and all help is greatly appreciated. 任何帮助都将不胜感激。
EDIT: Here's the jfiddle link: http://jsfiddle.net/4jNp8/ 编辑:这是jfiddle链接: http : //jsfiddle.net/4jNp8/
EDIT: Same JSFiddle, but with placeholders: http://jsfiddle.net/4jNp8/1/ 编辑:相同的JSFiddle,但带有占位符: http : //jsfiddle.net/4jNp8/1/
The simplest way is to add display:inline
block to the p
and img
tags: 最简单的方法是将display:inline
块添加到p
和img
标签:
#flip > * {
display: inline-block;
}
p
is a block level element, so unless you float
it, inline-block
it, or use some other positioning (such as display: table-cell) any content after it will not display inline with it. p
是一个块级元素,因此除非您float
, inline-block
它或使用其他定位方式(例如display:table-cell),否则任何内容将不会与其内联显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.