【发布时间】:2016-05-26 03:19:27
【问题描述】:
经过几个小时的挫折后,我决定问问你们;我用 JQuery 制作了一个照片滑块,在这种情况下显示为图像。通常它是一个 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;
}
【问题讨论】:
标签: html css image responsive-design photo