0
请troop981.com看一看:自动调整大小的背景,文本和annimated GIF嵌入
的Mountains.jpg与eagle.gif和可编辑的文本看起来像它在不同尺寸的观看时,悬挂在页面边缘监视器或放大时。
我想制作Mountains.jpg,并且jpg顶部的文本根据用户视图重新调整宽度和高度的大小。
以下代码是网页的HTML。我很感激任何帮助,因为我不知道任何有关HTML或CSS的信息,并且构建该网站的人不再与我们在一起。
<style>
.background_image
{
background:url(http://www.troop981.com/default/portals/0/Tatra_Mountains_Panorama_01.jpg); /* image to display */
width:1602px; /* width of image */
height:332px; /* height of image */
overflow:hidden; /* so div won't change size */
}
.eagle_image
{
height: 222px; /* use the actual height of the eagle gif */
width: 250px; /* use the actual width of the eagle gif */
background:url(http://www.troop981.com/default/portals/0/0049.gif) no-repeat; /* use your eagle filename */
position: absolute; top: 50px; /* adjust these to see the eagle move to where you want */
left: 40px; /* ditto from above */
}
.text_properties
{
padding-left:2px; /* position of text in inner div */
padding-top:2px; /* position of text in inner div */
padding-right:2px; /* position of text in inner div */
padding-bottom:2px; /* position of text in inner div */
color:darkgreen; /* text color */
font-size:40px; /* font size */
font-weight:bold; /* font weight */
font-family:script; /* font family */
margin-left:400px; /* left position of text */
margin-top:50px; /* top position of text */
}
</style>
<div class="background_image">
<div class="eagle_image"></div>
<div class="text_properties">Congratulations to Patrick Guilfoy – Troop 981’s 104th Eagle Scout</div>
</div>
罗伊,非常感谢!现在看起来更好。这解决了由宽度溢出页面的图像。文本然后返回到图像中的第二行,当在较小的屏幕上查看时,实际开始重叠第一行。我想我可以将它设置为两行,或者是否有一种简单的方法来实现可扩展? – user2095462 2013-02-21 15:22:39
我在左边空白处使用了1%,这可能会起作用。 – user2095462 2013-02-21 15:28:50
您可以设置一个线条高度。 “line-height:48px;” (“.text_properties”中没有引号)。你的文字是40px,这样你会得到4px页边距和4px页边距。如果你不完全满意,你可以玩弄它。恐怕老鹰会掩盖你的文字。因此,请尝试将文本设置在右侧。也许这会更好看。所以尝试添加“文本对齐:正确;” (不带引号).text_properties中 – Roy 2013-02-22 08:39:00