日期:2014-05-17  浏览次数:20555 次

高手花10分钟解救下菜鸟
如何在一行中,最左边显示图片,最右边显示文字……很简单是吧,怎么搞啊……只能用margin-left一个px一个px移动么,不会吧,太恐怖了……………………

------解决方案--------------------
<div style="float:left;">
    <img src="">

</div>

<div style="float:right;">
    <p>文字文字文字</p>
</div>


样式我直接写内联了,你用的时候写到CSS文件里面吧。。其实也就是用浮动或者定位就行了!希望对你有哦用!
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<style>
body,p{
margin:0px; padding:0px; font-size:12px;
}
.demo{
border:1px solid #f00; height:20px; overflow:hidden;
}
.demo p{
float:right;
}
.demo img{
float:left;}
</style>
<body>

<div class="demo">
<p>我是文字我是文字</p>
<img src="http://bs.baidu.com/uploadimg/32851366125140.jpg" width="50" height="20" />
</div>
</body>
</html>