大家好。
我有这个代码:
<div class="fl edit_options div_img">
<img class="img" src="${admin.img}" width="200px" height="200px" alt="Foto do Administrador" />
<div class="input_photo dropdowndiv"> <span>Alterar Foto</span>
<br />
<input type="file" name="file_photo" id="file_photo" value="Alterar Foto" />
</div>
<br />
<p>Administrador: ${admin.username}</p>
jQuery
$('.dropdowndiv').hide();
$('.div_img').hover(function() {
$(this).find('.dropdowndiv').slideUp('fast');
}, function() {
$(this).find('.dropdowndiv').slideDown('fast');
});
CSS:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
outline: none;
text-decoration: none;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after, q:before, q:after {
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.fl {
float: left;
}
.edit_options {
margin: 50px;
}
.div_img {
position: relative;
margin-right: 0px;
padding-left: 0px;
}
.edit_admin img, .edit_admin p {
text-align: center;
}
.input_photo {
position: absolute;
width: 200px;
height: 54px;
bottom: 20px;
background: rgba(170, 173, 168, 0.9);
display: table;
}
.input_photo span {
height: 54px;
display: table-cell;
vertical-align: middle;
text-align: center;
color: #000000;
}
.input_photo input {
position: absolute;
right: 0;
bottom: 0;
width: 200px;
height: 54px;
z-index: 2;
opacity: 0;
filter: alpha(opacity=0);
cursor: pointer;
}
如您所见,它没有按应有的方式工作,即在将鼠标悬停在图像上时显示 div。
我也相信我做的方式,太污染了。我相信在这种情况下有一种更优雅的方法可以达到相同的结果,我希望得到您的帮助。
我想小小姐。如果有人有一个插件可以让 jquery 上传照片,它会向我显示一个屏幕,用预定义的尺寸(200x200)调整图像的大小并在接受时进行剪切,将非常感激。
感谢。