因此,我目前正在构建一种“实时预览”,并且需要一个占位符图像,以便在信息输入到<input>
标记中时出现。我目前正在将此作为我的实时预览代码,用于页面上的文本字段,但无法使其适用于图像。图像显示在文本输入
$(function()
{
$(".companyname").keyup(function()
{
var companyname=$(this).val();
$(".cn_preview").html(companyname);
return false;
});
$(".tagline").keyup(function()
{
var tagline=$(this).val();
$(".tag_preview").html(tagline);
return false;
});
$(".map").keyup(function()
{
var map=$(this).val();
$(".map_preview").html(map);
return false;
});
$(".about").keyup(function()
{
var about=$(this).val();
$(".abt_preview").html(about);
return false;
});
占位符图像将相对于另一图像定位。该结构是这样的:
<div id="displaycontain">
<div id="previewbottom">
<h2 class="previewbottom">Preview Changes</h2>
<img src="images/previewimage.png" border="0" style="margin-left: auto; width: 100%;" />
</div>
<div class="action" id="publishbutton">
<input type="button" value="PUBLISH" class="myButton"></div>
<div id="test">
<h4 name="cnpreview" class="cn_preview">Company Name</h4>
<p name="tagprev" class="tag_preview">Tagline here.</p>
<p name="aboutprev" class="abt_preview">This is where your description goes.</p>
<img src="images/googlemap.png" name="mapplace" class="map_preview" border="0" />
</div>
</div>
而CSS为:
.cn_preview {
color: #000000;
font-size: 1.2em;
text-decoration: none;
font-weight: lighter;
position: relative;
top: -298px;
left: 78px;
width: 200px;
}
.tag_preview {
color: #000000;
font-size: .8em;
text-decoration: none;
font-weight: lighter;
position: relative;
top: -288px;
left: 78px;
width: 100px;
}
.abt_preview {
color: #000000;
font-size: .7em;
text-decoration: none;
font-weight: lighter;
position: relative;
top: -258px;
left: 78px;
width: 400px;
}
这可能是一个长镜头,但任何形式的帮助或方向去哪里将是有益的。
谢谢!
你想要一个占位符图像出现在哪里?你有什么尝试?什么不起作用?你想在占位符中有什么? – 2012-02-01 14:10:29
你能分享你的html吗? – giker 2012-02-01 14:17:18
编辑原创,让我知道你是否需要更多。 – nickdoesdesign 2012-02-01 14:25:57