【问题标题】:hovering background with opacity value and hovering button with opacity different value具有不透明度值的悬停背景和具有不透明度不同值的悬停按钮
【发布时间】:2019-03-06 05:23:15
【问题描述】:

我在应用悬停时面临简单的问题, 我的意思是我想悬停盒子,盒子的不透明度应该是 0.3 ,盒子里面的按钮应该是不透明度(1)。 所以我尝试应用此任务但没有运气。

当鼠标悬停在盒子上时,盒子的不透明度应该是 0.3,盒子里面的按钮应该是不透明度 (1)。

body {
  margin: .5em;
  padding: 0;
  height: 100%;
  background-color: #E8E8E8;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: .9em;
  direction: rtl;
}

#cell_1 {
  margin: 0 -3px 1em 0;
  padding: 8px;
  float: right;
  width: 61%;
  height: 100px;
  border-radius: 0px 20px 0px 0px;
  position: relative;
  background-color: #9BBB59;
  height: 100px;
}

.middle {
  transition: .5s ease;
  opacity: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  text-align: center;
}

#cell_1:hover {
  opacity: 0.3;
}

#cell_1:hover .middle {
  opacity: 1;
}

.text {
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  padding: 16px 32px;
}
<form id="form1" runat="server">
  <!--//end #postHeader//-->
  <div id="centerColumn">
    <!--//end #navbar//-->
    <div id="header" style="text-align:right">
      <asp:Image ID="Image1" runat="server" ImageUrl="~/APP_EOM/EO/Hed2.png" Width="100%" />
    </div>
    <!--//end #headern//-->
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <h2>&nbsp;</h2>
    <h2>&nbsp;</h2>
    <h2> heading 2:</h2>
    <p style="font-size:15px; line-height:1.5em; font-weight:normal">
      testiest test teset teset
    </p>
    <!-- Start Cell_1 -->
    <div id="cell_1" dir="rtl">
      <h2>????? ???????</h2>
      <p style="font-size:14px;  font-weight:normal"> ABCDEFG .</p>
      <p> </p>
      <div class="middle">
        <asp:Button ID="Button1" runat="server" CssClass="text" Text="teeeest" style="background-color: #297c1c;border:none;color:white;padding:7px 32px;text-align:right;text-decoration:none;cursor:pointer;" />
      </div>
    </div>
    <!--//end #cell_1//-->
  </div>
</form>

【问题讨论】:

    标签: html css asp.net


    【解决方案1】:

    你可以只使用不透明度而不是使用

    background: rgba(0, 0, 0, 0.5);
    

    【讨论】:

      【解决方案2】:

      您好,我解决了您的问题..根据您的代码,当您为父级提供不透明度时,它比其子级更小,那时它不会工作....所以调试一次下面的代码现在可以工作... pls check the below link

      enter code here
      

      【讨论】:

        【解决方案3】:

        将背景rgba 提供给#cell_1:before

        #cell_1 {
        	margin: 0 -3px 1em 0;
        	padding: 8px;
        	float: right;
        	width: 61%;
        	height: 100px;
        	border-radius: 0px 20px 0px 0px;
        	position: relative;
        	height: 100px;
        }
        #cell_1:before {
        	content: '';
        	position: absolute;
        	top: 0;
        	left: 0;
        	width: 100%;
        	height: 100%;
        	background-color: #9BBB59;
        	z-index: -1;
        }
        .middle {
        	transition: .5s ease;
        	opacity: 0;
        	position: absolute;
        	top: 50%;
        	left: 50%;
        	transform: translate(-50%, -50%);
        	-ms-transform: translate(-50%, -50%);
        	text-align: center;
        }
        #cell_1:hover:before {
        	background-color: rgba(155, 187, 89, .3);
        }
        #cell_1:hover .middle {
        	opacity: 1;
        }
        .my-btn {
        	background-color: green;
        	color: white;
        	font-size: 16px;
        	padding: 16px 32px;
        	cursor: pointer;
        }
        <!-- Start Cell_1 -->
        <div id="cell_1" dir="rtl">
          <h2>????? ???????</h2>
          <p style="font-size:14px;  font-weight:normal"> ABCDEFG  .</p>
          <div class="middle">
            <button class="my-btn">Test</button>
          </div>
        </div>
        <!--//end #cell_1//-->

        【讨论】:

          猜你喜欢
          • 2014-02-21
          • 1970-01-01
          • 2017-03-20
          • 2015-03-07
          • 2018-01-23
          • 2011-04-04
          • 1970-01-01
          • 1970-01-01
          • 2014-03-04
          相关资源
          最近更新 更多