我正试图在我的网站finegra.in上放置一个。以下是该网站的屏幕截图:
我只想在这里“访问我们的kickstarter项目”img:
以下是html和样式表:
<div id="page" class="hfeed">
<header id="branding" role="banner">
<!--
<nav id="access" role="navigation">
<h3 class="assistive-text">Main menu</h3>
<div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div>
<div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
<div class="menu"><ul><li class="current_page_item"><a href="http://www.finegra.in/" title="Home">Home</a></li></ul></div>
</nav><!~~ #access ~~>
-->
<hgroup>
<div>
<a href="http://www.finegra.in"><img id="logo" alt="fine grain Logo" src="http://www.finegra.in/wp-content/uploads/2012/04/fineGRAINlogoGOOD-WEB.png">
</a>
<img id="headerimg" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/headerimg2.jpg">
<a href="http://www.kickstarter.com/projects/finegrain/17408941?token=364cb635"><img id="branding" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/checkOurProject.png">
</a>
</div>
<div id="site-generator">
FineGrain LLC Copyright 2012. All Rights Reserved
</div>
</hgroup>
</header><!-- #branding -->
的style.css:
#branding {
border-top: 0px solid #BBBBBB;
padding-bottom: 10px;
position: relative;
z-index: 9999;
background: none repeat scroll 0 0 #DADAD2;
}
#headerimg {
width: 30% !important;
width: 100% !important;
}
#branding img {
margin-bottom: 20px;
width: auto;
}
.one-column #page {
max-width: 1500px;
}
.one-column #content {
margin: 0;
width: auto;
}
答案 0 :(得分:1)
假设您正在使用jQuery,您可以在DOM ready函数中为您的图像创建水印,并使其位置绝对并相对于图像进行计算。
<script type="text/javascript">
// Watermark image, change the src with your image's url
var watermark = '<img src="watermark.png" border="0" style="border:none; background-color:transparent; position:absolute; ';
// Position relative to image inside:
var insideTop = 20;
var insideLeft = 50;
$(document).ready(function () {
$("img").each(function (ix, el) {
var top = $(this).offset().top + insideTop;
var left = $(this).offset().left + insideLeft;
var imgWatermark = watermark + 'top:' + top + 'px; left:' + left + 'px;"/>';
$("body").append(imgWatermark);
});
});
</script>
如果您的图像具有水印和不具有的图像,请在图像中添加属性class =“withWatermark”,并用$(“替换脚本中的$(”img“)。 withWatermark“)。
<img src="myimage.jpg" class="withWatermark" />
$(".withWatermark").each(function (ix, el) {
答案 1 :(得分:0)
这样的事情怎么样? http://jsfiddle.net/UtKbC/
CSS:
.visit_project {
position: absolute;
top: 250px;
left: 400px;
}
HTML:
<a href="http://www.kickstarter.com/projects/finegrain/17408941?token=364cb635" class="visit_project"><img id="branding" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/checkOurProject.png">
</a>
将标题图像包装在自己的div中并将checkOurProject.png图像设置为基于该div包装器的绝对值可能更明智。
答案 2 :(得分:0)
我认为你可以通过简单的CSS在float的帮助下轻松完成: -
<强> CSS 强>
#header {
background: url("http://i.imgur.com/1nrC6.jpg");
width:1040px;
height:402px;
}
.logo {
float:right;
margin-top:200px;
}
<强> HTML 强>
<div id="header">
<a href="#"><img class="logo" src="http://i.imgur.com/17oqa.png"border="0"/></a>
</div>
请参阅演示: - http://jsfiddle.net/UtKbC/6/