处理 HTML/CSS 滑块的响应度
Dealing with responsivity on a HTML/CSS slider
我正在尝试在我的 Django 图像组件中创建一个图像滑块。到目前为止我已经这样设置了
{% extends './base.html' %} {% load static %} {% block content %}
<script src='../../static/pages/main.js'></script>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"
integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" />
<div class="gallery-container">
<img class="background-gallery" src="../../static/images/laptop_crop.png" />
<div id="slider">
<figure>
<img src="../../static/images/logo/kingict-okvir.png" />
<img src="../../static/images/logo/pwc-okvir.png" />
<img src="../../static/images/logo/degordian-okvir.png" />
</figure>
</div>
</div>
{% endblock %}
.gallery-container {
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.background-gallery {
max-width: 50%;
height: auto;
padding: 5em;
}
#slider {
overflow: hidden;
position: absolute;
width: auto;
max-width: 250px;
height: auto;
max-height: 250px;
margin-right: 10%;
margin-bottom: 12%;
}
#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
animation: 15s slider infinite;
}
#slider figure img {
width: 20%;
float: left;
}
@keyframes slider {
0% {
left: 0;
}
20% {
left: 0;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -200%;
}
100% {
left: -200%;
}
/* 100% {
left: -400%;
} */
}
`extends '../base.html' 只是扩展了我在每个网站上使用的一些元素,对滑块库没有影响
我的问题是,只要调整图像大小,它就会损坏。我正在寻找一种方法来使我当前的响应式响应或将其替换为响应式的响应。我意识到这是因为我显示的图像周围有白色边框,但我没有可以使用的任何其他格式的图像。
这张图片进一步解释了这个问题
希望这能让您入门。您可以为此创建媒体查询。我为 1400 像素或更低的屏幕添加了一个示例。但是你可以添加任意数量的:
https://jsfiddle.net/5yjvzh9k/
@media only screen and (max-width: 1400px) {
.background-gallery {
max-width: 70%;
}
#slider {
max-width: 250px;
max-height: 250px;
margin-right: 15%;
margin-bottom: 16%;
}
}
我正在尝试在我的 Django 图像组件中创建一个图像滑块。到目前为止我已经这样设置了
{% extends './base.html' %} {% load static %} {% block content %}
<script src='../../static/pages/main.js'></script>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"
integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" />
<div class="gallery-container">
<img class="background-gallery" src="../../static/images/laptop_crop.png" />
<div id="slider">
<figure>
<img src="../../static/images/logo/kingict-okvir.png" />
<img src="../../static/images/logo/pwc-okvir.png" />
<img src="../../static/images/logo/degordian-okvir.png" />
</figure>
</div>
</div>
{% endblock %}
.gallery-container {
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.background-gallery {
max-width: 50%;
height: auto;
padding: 5em;
}
#slider {
overflow: hidden;
position: absolute;
width: auto;
max-width: 250px;
height: auto;
max-height: 250px;
margin-right: 10%;
margin-bottom: 12%;
}
#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
animation: 15s slider infinite;
}
#slider figure img {
width: 20%;
float: left;
}
@keyframes slider {
0% {
left: 0;
}
20% {
left: 0;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -200%;
}
100% {
left: -200%;
}
/* 100% {
left: -400%;
} */
}
`extends '../base.html' 只是扩展了我在每个网站上使用的一些元素,对滑块库没有影响
我的问题是,只要调整图像大小,它就会损坏。我正在寻找一种方法来使我当前的响应式响应或将其替换为响应式的响应。我意识到这是因为我显示的图像周围有白色边框,但我没有可以使用的任何其他格式的图像。
这张图片进一步解释了这个问题
希望这能让您入门。您可以为此创建媒体查询。我为 1400 像素或更低的屏幕添加了一个示例。但是你可以添加任意数量的: https://jsfiddle.net/5yjvzh9k/
@media only screen and (max-width: 1400px) {
.background-gallery {
max-width: 70%;
}
#slider {
max-width: 250px;
max-height: 250px;
margin-right: 15%;
margin-bottom: 16%;
}
}