如何对下面一段单选按钮进行编码,使其在右边的图片上产生动画效果。

问题描述 投票:0回答:0

我正在制作附件截图中所示的页面。该页面有2个div部分(左&右部分)嵌套在一个主容器div中。我使用了以下HTML。

<div class="places" id="places">
  <img src="images/places-img.png" alt="places" />
  <div class ="placetext">
    <h2>Places</h2> 
    <p>Experience Japan...</p>
  </div>
</div

我还使用了以下CSS。

.places {
background-color: #000000;
height: 100%;
width: 100%;
display: block;}

.places img {
float: right;
width: 50%;
height: 100%;
display: inline-block;}

.placetext {
float: left;
width: 50%;
height: 100%;
display: inline-block;
position: absolute;}`

.placetext h2 {
display: inline-block;
position: relative;
margin-top: 30%;
color: white; 
font-family: Electroharmonix;
padding-left: 15%;
border-bottom: 5px solid #DC1A31;}

.placetext p {
color: #FFFFFF;
font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", "serif";
font-weight: 200;
text-align: justify;
font-size: 16px;
column-count: 2;
column-gap: 30px;
column-rule: 1px solid white;
margin: 0 8%;
line-height: 1.8;}

我想知道如何在文字下面加入那些单选按钮,并把它们链接到右边的图片上,这样当按钮被点击时,就可以让右边的图片像旋转木马一样,通过向左平稳地推送到下一张图片,从而实现慢速过渡。

在右边,我打算包括5张图片。

我对JavaScript了解不多,但我知道这可能需要它来对图像进行动画。

** 编辑。

我之前在一个图库上做了这个,但无论我怎么修饰,它都完全破坏了布局--Javascript。

    <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("dot");
  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";
}
</script>

截图

javascript html css
© www.soinside.com 2019 - 2024. All rights reserved.