如何防止调整窗口大小时图像移动
我目前正在开发此网站http://digitalgenesis.com.au/projects/sister/music。 html
当我调整屏幕大小时会发生什么,它最终与包含页面标题的 div 内容发生冲突,然后向下跳到错误的位置
http://digitalgenesis.com.au/projects/sister/img/screen.png
我想做的是让它在到达页面上的文本之前停止
任何人都可以提供有关如何执行此操作的建议
这是 html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/reset.css" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="musicbox">
<div id="musicheader">Music</div>
<div id="musicline"></div>
<div id="musiccontent">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris accumsan nunc vel odio faucibus euismod. Nulla semper lorem vel risus volutpat congue. Sed eleifend velit eget mauris luctus in imperdiet eros ultricies. Ut et gravida ligula. Vestibulum placerat placerat bibendum. Vestibulum pretium mollis arcu, et pharetra est sagittis sed. Vestibulum facilisis elementum urna vel fermentum. Vestibulum id metus at magna tristique ornare in id lorem. Nulla rhoncus, neque ac scelerisque varius, felis enim convallis ipsum, sed auctor libero dolor in ligula. Vivamus rhoncus, sapien non feugiat tempus, tortor enim euismod dolor, ac placerat ante enim sed diam. </div>
</div>
</div>
<div id="musicimg"><img src="img/katrina.jpg" alt="#" /></div>
</body>
</html>
CSS 是
@font-face {
font-family: 'CodeLightRegular';
src: url('../fonts/code/code_light_copy-webfont.eot');
src: url('../fonts/code/code_light_copy-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/code/code_light_copy-webfont.woff') format('woff'),
url('../fonts/code/code_light_copy-webfont.ttf') format('truetype'),
url('../fonts/code/code_light_copy-webfont.svg#CodeLightRegular') format('svg');
font-weight: normal;
font-style: normal;
}
#wrap{width:960px; margin:0 auto;}
#musicheader{font-size:120px; font-family: 'CodeLightRegular'; }
#musicbox{float:left; width:519px; }
#musicline{height:4px; background:black; }
#musicimg{float:right; width:441px; }
#musiccontent{width:120%;}
#clear{clear:both;}
Im currently developing this site http://digitalgenesis.com.au/projects/sister/music.html
What happens when i re-size screen is that it eventually collides with the div contents holding page title and then jumps down a line into the wrong position
http://digitalgenesis.com.au/projects/sister/img/screen.png
What i'd like to do is have it stop just before it hits the text on the page
Can anyone offer suggestions on how to do this
Here is the html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/reset.css" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="musicbox">
<div id="musicheader">Music</div>
<div id="musicline"></div>
<div id="musiccontent">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris accumsan nunc vel odio faucibus euismod. Nulla semper lorem vel risus volutpat congue. Sed eleifend velit eget mauris luctus in imperdiet eros ultricies. Ut et gravida ligula. Vestibulum placerat placerat bibendum. Vestibulum pretium mollis arcu, et pharetra est sagittis sed. Vestibulum facilisis elementum urna vel fermentum. Vestibulum id metus at magna tristique ornare in id lorem. Nulla rhoncus, neque ac scelerisque varius, felis enim convallis ipsum, sed auctor libero dolor in ligula. Vivamus rhoncus, sapien non feugiat tempus, tortor enim euismod dolor, ac placerat ante enim sed diam. </div>
</div>
</div>
<div id="musicimg"><img src="img/katrina.jpg" alt="#" /></div>
</body>
</html>
And the css is
@font-face {
font-family: 'CodeLightRegular';
src: url('../fonts/code/code_light_copy-webfont.eot');
src: url('../fonts/code/code_light_copy-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/code/code_light_copy-webfont.woff') format('woff'),
url('../fonts/code/code_light_copy-webfont.ttf') format('truetype'),
url('../fonts/code/code_light_copy-webfont.svg#CodeLightRegular') format('svg');
font-weight: normal;
font-style: normal;
}
#wrap{width:960px; margin:0 auto;}
#musicheader{font-size:120px; font-family: 'CodeLightRegular'; }
#musicbox{float:left; width:519px; }
#musicline{height:4px; background:black; }
#musicimg{float:right; width:441px; }
#musiccontent{width:120%;}
#clear{clear:both;}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTML5 解决方案是使用媒体查询根据宽度来设置不同的页面样式:
在您的
base.css
中,您将拥有所有常见的样式以及适用于较小屏幕的任何样式。在您的main.css
中,您将覆盖更大的屏幕。(换句话说,您需要首先考虑小屏幕设计 css,然后添加 css 以使其在大屏幕上看起来不错。)
更新:-
例如尝试:
a HTML5 solution would be to use media queries to style the page differently depending on width:
in your
base.css
you would have all the common styling plus any styling for smaller screens. In yourmain.css
you would have overrides for the larger screen.(In other words you need to design your css with the small screen in mind first and then add css to make it look nice on larger screens.)
UPDATE:-
For example try:
正如 dan 所说,您可以将其用作具有
background-position; 的
&表示您希望文本不与图像重叠,因此您可以指定背景图像
;顶部:0;右:0;不重复min-width
as dan said you can use it as a
background image
withbackground-position; top:0; right:0; no-repeat
& said your want that the text is not overlap the image for that you can givemin-width