gpt4 book ai didi

html - 如何为所有屏幕尺寸显示 100% 和自定义高度的图像

转载 作者:行者123 更新时间:2023-11-28 09:48:57 25 4
gpt4 key购买 nike

我有一个水平 slider ,我需要使其响应,以便其中使用的图像可以采用任何可用屏幕的大小。我在这里面临的问题是图像从屏幕右侧被剪切我不想要。

这是我的 HTML..

    <div id="sliderFrame">
<div id="slider">
<img src="images/1.jpg" style="width:100%;" alt="" />
<img src="images/2.jpg" style="width:100%;" alt="" />
</div>
</div>

这是我的完整 CSS。如果 Css 太长,我很抱歉,但说真的,我无法找出我应该更改哪个属性以获得结果。

 #sliderFrame 
{
position:relative;
width:100%;
}

#slider, #slider div.sliderInner {
width:100%;height:306px;/* Must be the same size as the slider images */
}

#slider {
background:#fff url(loading.gif) no-repeat 50% 50%;
position:relative;
margin:0 auto; /*center-aligned*/
transform: translate3d(0,0,0);
box-shadow: 0px 1px 5px #999999;
}

/* image wrapper */
#slider a.imgLink, #slider div.video {
z-index:2;
position:absolute;
top:0px;left:0px;border:0;padding:0;margin:0;
width:100%;height:100%;
}
#slider .video {
background:transparent url(video.png) no-repeat 50% 50%;
}

/* Caption styles */
#slider div.mc-caption-bg, #slider div.mc-caption-bg2 {
position:absolute;
width:100%;
height:auto;
padding:10px 0;/* 10px will increase the height.*/
left:0px; /*if the caption needs to be aligned from right, specify by right instead of left. i.e. right:20px;*/
bottom:0px;/*if the caption needs to be aligned from top, specify by top instead of bottom. i.e. top:150px;*/
z-index:3;
overflow:hidden;
font-size: 0;
}
#slider div.mc-caption-bg
{
/* NOTE: Its opacity is to be set through the sliderOptions.captionOpacity setting in the js-image-slider.js file.*/
background:Black;/* or any other colors such as White, or: background:none; */
}
#slider div.mc-caption-bg2 {
background:none;
}
#slider div.mc-caption {
font: bold 14px/20px Arial;
color:#EEE;
z-index:4;
text-align:center;
background:none;
}
#slider div.mc-caption a {
color:#FB0;
}
#slider div.mc-caption a:hover {
color:#DA0;
}


/* ------ built-in navigation bullets wrapper ------*/
/* Note: check themes\2\js-image-slider.css to see how to hide nav bullets */
#slider div.navBulletsWrapper {
top:320px;/* Its position is relative to the #slider */
text-align:center;
background:none;
position:relative;
z-index:5;
}

/* each bullet */
#slider div.navBulletsWrapper div
{
width:11px; height:11px;
font-size:0;color:White;/*hide the index number in the bullet element*/
background:transparent url(bullet.png) no-repeat 0 0;
display:inline-block; *display:inline; zoom:1;
overflow:hidden;cursor:pointer;
margin:0 6px;/* set distance between each bullet*/
}

#slider div.navBulletsWrapper div.active {background-position:0 -11px;}


/* --------- Others ------- */

#slider div.loading
{
width:100%; height:100%;
background:transparent url(loading.gif) no-repeat 50% 50%;
filter: alpha(opacity=60);
opacity:0.6;
position:absolute;
left:0;
top:0;
z-index:9;
}

#slider img, #slider>b, #slider a>b {
position:absolute; border:none; display:none;
}

#slider div.sliderInner {
overflow:hidden;
-webkit-transform: rotate(0.000001deg);/* fixed the Chrome not crop border-radius bug*/
position:absolute; top:0; left:0;
}

#slider>a, #slider video, #slider audio {display:none;}

这是截图的图像,它不是完整的图像,它是从原始图像的右端截取的 Image

最佳答案

要使图像具有响应性,请使用广泛使用的 img 标签代码段

#slider > img {
display: block;
max-width: 100%;
height: auto;
}

关于html - 如何为所有屏幕尺寸显示 100% 和自定义高度的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25159505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com