CSS position 问题

oWeiZhiMuBiao12 2012-10-25 02:29:42
用css定位图片放大缩小浏览器图片位置会改变求解
{
position:absolute;
left:100px;
top:150px
}
...全文
291 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
oWeiZhiMuBiao12 2012-10-28
  • 打赏
  • 举报
回复
我想放大缩小时logo会和背景一起缩放 背景要是div定位会漏白边
test2500 2012-10-27
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

[Quote=引用 6 楼 的回复:]
<html>
<head>
<title>Img</title>
这是啥意思啊
[/Quote]
连这个也不懂,真心觉得你应该重新学html……
oWeiZhiMuBiao12 2012-10-27
  • 打赏
  • 举报
回复
<script type="text/javascript"><!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("menu");
var allli = navRoot.getElementsByTagName("li")
for (i=0; i<allli.length; i++) {
node = allli[i];
node.onmouseover=function() {
this.className+=" current";
}
node.onmouseout=function() {
this.className=this.className.replace(" current", "");
}
}
}
}
window.onload=startList;
//--><!]]></script>

这段脚本啥意思啊
Lunatree 2012-10-26
  • 打赏
  • 举报
回复
给图片的父元素加属性position:relative;
然后再写你这段代码就可以了
oWeiZhiMuBiao12 2012-10-26
  • 打赏
  • 举报
回复

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> 淘宝网 </title>//
<style type="text/css">
body {
background-image: url(wow1.jpg);
background-position: center top;
margin: auto;
height: 4772px;
width: 1500px;
}
#logo{
background-attachment: fixed;
background-image: url(wasdnav-bg.png);
background-repeat: no-repeat;
background-position: center 15px;
height: 152px;
}
#img{
position:absolute;
left: 481px;
top: 73px;
height: 164px;
width: 762px;
}
</style>
</head>
<body>
<div id="logo">
<img id="img" src="../nav-bar-tw.gif"/></div>
</body>
</html>
我这样弄得
KK3K2005 2012-10-26
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
用css定位图片放大缩小浏览器图片位置会改变求解
{
position:absolute;
left:100px;
top:150px
}
[/Quote]

你们真厉害阿
他的 问题上下文都没交代清楚
你们已经可以 回答了
sunwenjunnet 2012-10-26
  • 打赏
  • 举报
回复
<title>Img</title>是你整个网页的标题啊
oWeiZhiMuBiao12 2012-10-25
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]

.eshop .shop-header{background:#e1e1e1 url(http://img08.taobaocdn.com/tps/i8/T1sftpXXhfXXXXXXXX-5-150.png) 0 0 repeat-x;}.eshop .shop-header h2{color:#fff;}.eshop .shop-header .shop……
[/Quote]

这是一段
oWeiZhiMuBiao12 2012-10-25
  • 打赏
  • 举报
回复

.eshop .shop-header{background:#e1e1e1 url(http://img08.taobaocdn.com/tps/i8/T1sftpXXhfXXXXXXXX-5-150.png) 0 0 repeat-x;}.eshop .shop-header h2{color:#fff;}.eshop .shop-header .shop-summary p{color:#fff;}.eshop .shop-header .nav,.eshop .shop-header .nav li a,.eshop .shop-header .nav li a em,.box .hd,.shopkeeper .box .hd{background:url(http://img06.taobaocdn.com/tps/i6/T1v2tpXndeXXXXXXXX-200-199.png) 0 0 no-repeat;}.eshop .shop-header .nav{background-position:0 -100px;background-repeat:repeat-x;}.eshop .shop-header .nav li a{background-position:100% -25px;}.eshop .shop-header .nav li a em{background-position:0 0;}.eshop .shop-header .nav li.current a{background-position:100% -75px;}.eshop .shop-header .nav li.current a em{background-position:0 -50px;}.eshop .shop-header .nav a:link,.eshop .shop-header .nav a:visited{color:#666;}.eshop .shop-header .nav a:hover,.eshop .shop-header .nav a:active{color:#666;}.eshop .shop-header .nav .current a:link,.eshop .shop-header .nav .current a:visited{color:#fff;}.eshop .shop-header .nav .current a:hover,.eshop .shop-header .nav .current a:active{color:#fff;}.col-main .box .hd{border-color:#5C97FF;background-color:#e1e1e1;background-position:0 -129px;background-repeat:repeat-x;}.col-main .box .bd{background-color:#fff;}.col-main .box .hd h3{color:#5A5A5A;}.box .hd,.shopkeeper .box .hd{border-color:#CCC;background-color:#e1e1e1;background-position:0 -153px;background-repeat:repeat-x;}.box .bd,.shopkeeper .box .hd,.shopkeeper .box .bd{border-color:#CCC;}.box .hd h3,.shopkeeper .box .hd h3{color:#5A5A5A;}

啥意思求解啊
oWeiZhiMuBiao12 2012-10-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
<html>
<head>
<title>Img</title>
这是啥意思啊
test2500 2012-10-25
  • 打赏
  • 举报
回复
<html>
<head>
<title>Img</title>
<style type = "text/css">
#imgContainer
{
position:relative;
}
#myImg{
position:absolute;
left:100px;
top:150px;
}
</style>
</head>

<body>
<div id="imgContainer">
<img id="myImg" src="捕获2.jpg"/>
</div>

</body>
</html>
可能是你在<style></style>没写<style type = "text/css">吧
oWeiZhiMuBiao12 2012-10-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
郁闷,今天怎么老打错字,上面都是错的,这下保证对的:

HTML code

<style>
#imgContainer
{
position:relative;
}
#myImg{
position:absolute;
left:100px;
top:150px;
}
</style>

……
[/Quote]
按照你的格式弄了为啥还不行呢
oWeiZhiMuBiao12 2012-10-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
郁闷,今天怎么老打错字,上面都是错的,这下保证对的:

HTML code

<style>
#imgContainer
{
position:relative;
}
#myImg{
position:absolute;
left:100px;
top:150px;
}
</style>

……
[/Quote]

谢谢了
云水千寻 2012-10-25
  • 打赏
  • 举报
回复
郁闷,今天怎么老打错字,上面都是错的,这下保证对的:

<style>
#imgContainer
{
position:relative;
}
#myImg{
position:absolute;
left:100px;
top:150px;
}
</style>

<div id="imgContainer">
<img id="myImg" src="example.jpg"/>
</div>
云水千寻 2012-10-25
  • 打赏
  • 举报
回复
抱歉,上面的代码有误,下面是修改后的结果:

<style>
#imgContainer
{
position:relative;
}
#myImg{
position:absolute;
left:100px;
top:150px
}
<style/>

<div id="imgContainer">
<img id="myImg" src="example.jpg"/>
<div/>
云水千寻 2012-10-25
  • 打赏
  • 举报
回复
如果你的图片元素img有一个父元素,请将父元素进行定位,比如:
<style>
imgContainer
{
position:relative;
}
myImg{
position:absolute;
left:100px;
top:150px
}
<style/>

<div id="imgContainer">
<img id="myImg" src="example.jpg"/>
<div/>

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧