【问题标题】:HTML Elements on webpage are displaying wrong网页上的 HTML 元素显示错误
【发布时间】:2020-06-23 08:59:05
【问题描述】:

当您访问 thedaystaragency.com/home 并向下滚动到我们的服务时,灯泡所在的位置全部错位且无法正常工作。这是我正在使用的代码,我现在删除了按钮,因为由于某种原因 elementor 不允许按钮正常工作,如果可以推荐任何解决方案,我将不胜感激! :)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Change Image on Hover in CSS</title>
<style>
#myBtn{
  padding: 15px 25px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

#lightbulb:hover img{
    content:url("https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png");
}
  
  
#lightbulb:hover p { font-weight:bold; }
}
</style>
</head>
<body>
    <center>
    <div id=lightbulb >
 <img src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" onmouseover=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png" onmouseout=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" width=25px;> <br> <br> <h2> hi</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</span></p>

}

对于我试图做这样的事情的按钮:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#more {display: none;}
</style>
</head>
<body>

<h2>Read More Read Less Button</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</span></p>
<button onclick="myFunction()" id="myBtn">Read more</button>

<script>
function myFunction() {
  var dots = document.getElementById("dots");
  var moreText = document.getElementById("more");
  var btnText = document.getElementById("myBtn");

  if (dots.style.display === "none") {
    dots.style.display = "inline";
    btnText.innerHTML = "Read more"; 
    moreText.style.display = "none";
  } else {
    dots.style.display = "none";
    btnText.innerHTML = "Read less"; 
    moreText.style.display = "inline";
  }
}
</script>

</body>
</html>

【问题讨论】:

  • 实际行为与预期行为是什么? (我真的不明白“都未对齐并且无法正常工作”)
  • 请告诉人们您有什么错误,以及您已经尝试过什么。这可以让人们更好地帮助您。

标签: javascript html css wordpress elementor


【解决方案1】:

不确定您的目标是什么,但未对齐的原因是最后一个灯泡 div 没有被包裹在与前三个相同的 div 结构中。

【讨论】:

    【解决方案2】:

    我建议您避免将整个段落切换为粗体文本。你可能会使用这样的东西:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Change Image on Hover in CSS</title>
    <style>
    #myBtn{
      padding: 15px 25px;
      font-size: 24px;
      text-align: center;
      cursor: pointer;
      outline: none;
      color: #fff;
      background-color: #4CAF50;
      border: none;
      border-radius: 15px;
      box-shadow: 0 9px #999;
    }
    
    #lightbulb:hover img{
        content:url("https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png");
    } 
      
    #lightbulb:hover p { 
      box-shadow: -26px 10px 37px -4px rgba(220,220,220,1);
      background-color: rgba(204, 245, 245, 0.5);
    }
    
    .text {
      box-sizing: border-box;
      padding: 5px;
      text-align: justify;
      transition-duration: 700ms;
    
    }
    
    </style>
    </head>
    <body>
        <center>
        <div id=lightbulb >
     <img src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" onmouseover=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png" onmouseout=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" width=25px; <br> <br> <h2> hi</h2> <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</p>

    【讨论】:

      【解决方案3】:

      实际上我尝试了这个解决方案,多亏了你的洞察力,它似乎奏效了!

      `enter code here`<!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="utf-8">
      <title>Change Image on Hover in CSS</title>
      <style>
      
      #gears:hover img{
          content:url("https://thedaystaragency.com/wp-content/uploads/2020/03/LogoMakr_5dF3BF.png");
      }
      #gears img { padding-bottom:15px;
      }
      
        #gears p{ font-family:raleway;
        font-size:15px;
        font-weight:400;
        }
        
        #gears h2{ font-family:raleway;
        font-size:20px;
          font-weight:400;
        }
      
        
        #gears:hover h2{ color:#04A4CC; }
      }
      
      
      </style>
      </head>
      <body>
          <br>
          <center>
          <div id=gears >
       <img src="https://thedaystaragency.com/wp-content/uploads/2020/03/LogoMakr_5i5JYt.png" onmouseover=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/LogoMakr_5dF3BF.png" onmouseout=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/LogoMakr_5i5JYt.png" wwidth=45px; <br> <br> <h2> OPERATIONAL CONTROLS</h2> <p>At Cannabrand, we like to make sure you are profitable at every stage of the production process. We focus on process re-engineering. <br>
       [expand title="Read More" swaptitle="Close" trigpos="below" trigclass="my_button"]
       We streamline business' supply-side activities to maximize customer value and gain competitive advantage in an increasingly competitive marketplace. Cannabrand’s operations experts will help streamline and structure production, product development, and information systems needed to decrease costs, increase efficiency, and increase the velocity of money flowing through the company. By managing the overall supply chain, we help our partners to increase and maintain a competitive advantage. [/expand]</p> <br>
                

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-10-17
        • 1970-01-01
        • 2014-08-25
        • 2014-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多