Html 如何控制缩略图的div容器的宽度?

Html 如何控制缩略图的div容器的宽度?,html,css,width,thumbnails,Html,Css,Width,Thumbnails,我无法更改包含以下缩略图的列的宽度。我希望纵向图像的容器是图像的大小,就像横向图像的容器等于图像一样,这样图像之间就没有额外的空间。我尝试的每件事都会产生不同大小的图像,而不会影响容器的大小,容器的大小始终等于较大的风景图像的尺寸。有人能帮忙吗?谢谢 <!DOCTYPE html> <html> <style> body { font-family: Arial; margin: 0; } * { box-sizing: border-box;

我无法更改包含以下缩略图的列的宽度。我希望纵向图像的容器是图像的大小,就像横向图像的容器等于图像一样,这样图像之间就没有额外的空间。我尝试的每件事都会产生不同大小的图像,而不会影响容器的大小,容器的大小始终等于较大的风景图像的尺寸。有人能帮忙吗?谢谢

<!DOCTYPE html>
<html>
<style>
body {
  font-family: Arial;
  margin: 0;
}

* {
  box-sizing: border-box;
}

img {
  vertical-align: middle;
}

.center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50%;
}

/* Position the image container (needed to position the left and right arrows) */
.container {
  position: relative;
}

/* Hide the images by default */
.mySlides {
  display: none;
    margin: auto;
}

/* Add a pointer when hovering over the thumbnail images */
.cursor {
  cursor: pointer;
}

/* Next & previous buttons */
.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 40%;
  width: auto;
  padding: 16px;
  margin-top: -50px;
  color: white;
  font-weight: bold;
  font-size: 20px;
  border-radius: 0 3px 3px 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* Container for image text */
.caption-container {
  text-align: center;
  background-color: white;
  padding: 35px;
  color: black;
  font-size: 1.1em;
}

.row {
    display: flex;
    justify-content: center;
    }

/* Six columns side by side */
.column {
  float: left;
  max-width: 10%;
}

    /* Add a transparency effect for thumnbail images */
.demo {
  opacity: 0.6;
}

.active,
.demo:hover {
  opacity: 1;
}

</style>

<body>

        <div class="container">

            <div class="mySlides">
                <div class="numbertext">1 / 4</div>
                    <img src="img_144-109.JPG" style="height:80%" class="center">
                        </div>

            <div class="mySlides">
                <div class="numbertext">2 / 4</div>
                    <img src="img_144-133.jpg" style="width:20%" class="center">
                        </div>

            <div class="mySlides">
                <div class="numbertext">3 / 4</div>
                    <img src="img_free_admission.JPG" style="width:20%" class="center">
                        </div> 

            <div class="mySlides">
                <div class="numbertext">4 / 4</div>
                    <img src="img_154-043.jpg" style="height:80%" class="center">
                        </div>

  <a class="prev" onclick="plusSlides(-1)">❮</a>
  <a class="next" onclick="plusSlides(1)">❯</a>

  <div class="caption-container">
    <p id="caption"></p>
        </div>

            <div class="row">
                <div class="column">
                    <img class="demo cursor" src="https://www.bartonlewisfilm.com/img_144-109.JPG" style="width:100%" onclick="currentSlide(1)" alt="144-109, Dyckman St., IND Eighth Ave. Line">
                        </div>

                 <div class="column">
                    <img class="demo cursor" src="https://www.bartonlewisfilm.com/img_144-133.jpg" style="width:50%" onclick="currentSlide(2)" alt="144-133, Dyckman St., IND Eighth Ave. Line">
                        </div>    

                <div class="column">
                    <img class="demo cursor" src="https://www.bartonlewisfilm.com/img_free_admission.JPG" style="width:50%" onclick="currentSlide(3)" alt="free admission, Greenpoint Ave., IND Crosstown Line">
                        </div> 

                <div class="column">
                    <img class="demo cursor" src="https://www.bartonlewisfilm.com/img_154-043.jpg" style="width:100%" onclick="currentSlide(4)" alt="154-043, 116th St., IND Eighth Ave. Line">
                        </div>

            </div>
    </div>

<script>
var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("demo");
  var captionText = document.getElementById("caption");
  if (n > slides.length) {slideIndex = 1}
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
  }
  for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";
  dots[slideIndex-1].className += " active";
  captionText.innerHTML = dots[slideIndex-1].alt;
}
</script>

</body>
</html>

身体{
字体系列:Arial;
保证金:0;
}
* {
框大小:边框框;
}
img{
垂直对齐:中间对齐;
}
.中心{
显示:块;
左边距:自动;
右边距:自动;
宽度:50%;
}
/*定位图像容器(需要定位左右箭头)*/
.集装箱{
位置:相对位置;
}
/*默认情况下隐藏图像*/
迈斯利德斯先生{
显示:无;
保证金:自动;
}
/*将光标悬停在缩略图上时添加指针*/
.光标{
光标:指针;
}
/*下一步和上一步按钮*/
.prev,
.下一个{
光标:指针;
位置:绝对位置;
最高:40%;
宽度:自动;
填充:16px;
利润上限:-50px;
颜色:白色;
字体大小:粗体;
字体大小:20px;
边界半径:0 3px 3px 0;
用户选择:无;
-webkit用户选择:无;
}
/*将“下一步按钮”置于右侧*/
.下一个{
右:0;
边界半径:3px 0 3px;
}
/*在悬停时,添加一个黑色背景色,带有一点透明*/
.prev:悬停,
.下一步:悬停{
背景色:rgba(0,0,0,0.8);
}
/*数字文本(1/3等)*/
.numbertext{
颜色:#F2F2;
字体大小:12px;
填充:8px 12px;
位置:绝对位置;
排名:0;
}
/*图像文本的容器*/
.标题容器{
文本对齐:居中;
背景色:白色;
填充:35px;
颜色:黑色;
字体大小:1.1米;
}
.行{
显示器:flex;
证明内容:中心;
}
/*六列并排*/
.栏目{
浮动:左;
最大宽度:10%;
}
/*为thumnbail图像添加透明度效果*/
.演示{
不透明度:0.6;
}
.主动,
.演示:悬停{
不透明度:1;
}
1/4
2/4
3/4
4/4
❮
❯

var slideIndex=1; 放映幻灯片(幻灯片索引); 函数加滑块(n){ 放映幻灯片(幻灯片索引+=n); } 功能当前幻灯片(n){ 放映幻灯片(幻灯片索引=n); } 功能演示幻灯片(n){ var i; var slides=document.getElementsByClassName(“mySlides”); var dots=document.getElementsByClassName(“演示”); var captionText=document.getElementById(“caption”); 如果(n>slides.length){slideIndex=1} 如果(n<1){slideIndex=slides.length} 对于(i=0;i
您能删除所有不必要的代码吗?只留下对你的问题很重要的代码。你的问题有两个止步符:1。您没有显示图像,因此我们不知道它们的尺寸,因此我们无法看到代码的作用。二,。你不是在问问题,也不是在描述你想要的行为/功能。我也在问问题——不知道为什么你不清楚。我想使较小(纵向)图像的缩略图容器的大小等于图像的大小,就像横向缩略图一样。至于没有显示的图像,当我运行代码片段时,我能够看到它们。唯一不需要显示问题的代码是样式标记上方的代码,我删除了它。