[英]responsive web design fluid image
我正在使用MVC剃刀代码生成网站徽标,并在调整网站大小时难以进行图像缩放。 我尝试使用image = max-width:100%
and height:auto
但它不起作用!
这是我的代码:
<div class="float-left">
<p class="site-title">@Html.ActionLink(" ", "Home", "Home", null, new {@class = "crown_logo"})</p>
</div>
a.crown_logo {
display:block;
width:284px;
height:87px;
background-image :url("../GUI/Images/rsz_crown_2.png");
text-indent: -9999px; /* hides the link text */
}
在这里检查小提琴,它应该可以帮助您解决问题: 响应式图像 此处解释了 CSS的整个概念:
img.responsive_logo
{
position: absolute;
max-width: 80%;
top: 10%;
left: 10%;
border-radius: 3px;
box-shadow: 0 3px 6px rgba(0,0,0,0.9);
}
img.responsive_logo:empty
{
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
@media screen and (orientation: portrait) {
img.responsive_logo {
max-width: 90%;
}
}
@media screen and (orientation: landscape) {
img.responsive_logo {
max-height: 90%;
}
}
编辑:使用实际图像而不是背景图像样式。 最初,您的图片必须具有尺寸,因为它应以100%的宽度和100%的高度显示。
<div class="float-left">
<a href='@Url.Action("Home", "Home")'><img src="ImageSource" class="responsive_logo" /></a>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.