gpt4 book ai didi

html - 请居中和响应式图像 slider 清洁解决方案

转载 作者:行者123 更新时间:2023-11-28 05:50:25 26 4
gpt4 key购买 nike

经过几个小时的挫折,我决定只问问你们;我用 JQuery 制作了一个照片 slider ,在这种情况下显示为图像。通常它是一个 div。我希望 div 可以缩放并在垂直和水平方向上居中。现在因为图像有宽度和高度(所有图像都有)我不能让它和 div 一样,因为它有不同的测量值。我不希望图像在宽度和高度上都大于 div,但我确实希望图像随显示的 div 缩放。

请提前帮助并感谢,

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>name</title>

<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/reset.css">

</head>
<body>
<header>
<mark><h1>NAME</h1></mark>
<h2>WEBSITE</h2>
</header>

<section id="upperContainer"><article id="leftBlock"></article><article id="rightBlock"><div id="photoPluginHolder"><img id="photoHolder" src="images/huis1.png"></div></div></article>
</section>


<section id="lowerContainer"><article id="leftBlock2"></article><article id="rightBlock2"></article></section>

<section id="about"></section>
<footer></footer>
</body>
</html>

CSS

    body
{
background-color: black;
max-width: 100%;
height: 100%;
}

@font-face
{
font-family: fontje;
src: url(../fonts/tunga.ttf);
}

header
{
width: 100%;
height: 15vh;
max-height: 8vw;
/*background-image: url(../images/profile.png);*/
background-color: white;
}

h1
{
font-family: fontje;
font-size: 5vw;
max-height: 5vw;
line-height: 1;
color: #333333;
}

h2
{
font-family: fontje;
font-size: 2vw;
max-height: 2vw;
line-height: 0.1;
color: #333333;
}

#upperContainer
{
width: 100%;
max-width: 100%;
height: 60vh;
background-color: brown;
text-align: center;
}

#leftBlock
{
width: 50%;
height: 60vh;
max-height: 60vh;
background-color: orange;
display: inline-block;
vertical-align: middle;
}

#rightBlock
{
width: 50%;
height: 60vh;
max-height: 60vh;
background-color: blue;
display: inline-block;
vertical-align: middle;
}

#lowerContainer
{
width: 100%;
max-width: 100vw;
max-height: 60vh;
background-color: brown;
text-align: center;
}

#leftBlock2
{
width: 50%;
height: 60vh;
max-height: 60vh;
background-color: purple;
display: inline-block;
vertical-align: middle;
}

#rightBlock2
{
width: 50%;
height: 60vh;
max-height: 60vh;
background-color: green;
display: inline-block;
vertical-align: middle;
}

#about
{
width: 100%;
height: 90vh;
background-color: pink;
}

footer
{
width: 100%;
height: 15vh;
background-color: white;
}

/*photogeval*/
#photoPluginHolder
{

}

#photoHolder
{


}

#photoHolder > img
{

width: 92%;
max-width: 100%;
max-height: 100%;
display: table;
}


#arrowLeftHolder
{

}

#arrowLeft
{



}

#arrowRightHolder
{


}

#arrowRight
{

}

#arrowLeft:hover
{
cursor: pointer;
}

#arrowRight:hover
{
cursor: pointer;
}

#arrowLeftHolder:hover
{
background-color: rgba(0, 0, 0, 0.225);
cursor: pointer;
}

#arrowRightHolder:hover
{
background-color: rgba(0, 0, 0, 0.225);
cursor: pointer;
}

最佳答案

替换

#photoPluginHolder
{

}

#photoHolder
{


}

#photoHolder > img
{

width: 92%;
max-width: 100%;
max-height: 100%;
display: table;
}

与:

#photoPluginHolder
{
width:100%;
height:100%;
text-align:center;
}

#photoPluginHolder:before {
content: '';
height: 100%;
display: inline-block;
vertical-align: middle;
}


#photoHolder
{
max-width: 100%;
max-height: 100%;
display: inline-block;
vertical-align: middle;
}

关于html - 请居中和响应式图像 slider 清洁解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37367686/

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