亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

設置正文的寬度和邊距后 HTML <button> 不起作用

設置正文的寬度和邊距后 HTML <button> 不起作用

阿波羅的戰車 2023-10-24 15:13:14
我有一個帶有按鈕的簡單 html:body {  background-color: White;  font-family: 'Roboto', sans-serif;  width: 800px;  margin: 0 auto;}div.container_body_content {  margin-top: 10px;  margin-bottom: 10px;  margin-left: 10px;  margin-right: 10px;}div.buttondiv {  width: 100%;  height: auto;  border: 1px solid black;  display: flex;  align-items: center;  justify-content: center;}.button {  background-color: #93d00f;  border: none;  color: black;  padding: 10px 20px;  text-align: center;  text-decoration: none;  display: inline-block;  margin: 4px 2px;  cursor: pointer;  border-radius: 16px;}.button:hover {  background-color: Green;}<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet"><div class="container_body_content">  <div class="buttondiv">    <button class="button"><span style="color:White;font-family:'Roboto';font-weight:bold;">Test Button</span></button>  </div></div>當我注釋掉width: 800px; margin: 0 auto;正文時,按鈕工作正常,并在懸停時將背景顏色更改為綠色。但是,如果我width: 800px; margin: 0 auto;設置了正文,則該按鈕根本不起作用,這意味著懸停時背景顏色不會更改為綠色。我需要的是即使當我減小主體寬度時,按鈕也能具有懸停效果。我似乎無法弄清楚發生了什么事,我做錯了什么?謝謝奇怪的是,在代碼片段中它可以工作,但是當我在 Safari 或 Google Chrome 中打開它時,它卻不能,這就是我這邊的樣子:
查看完整描述

1 回答

?
慕雪6442864

TA貢獻1812條經驗 獲得超5個贊

謎團解開了,我剛剛發現了一個流氓 DIV,我將其“放置”在我的 div.buttondiv 之上。在代碼片段中它可以工作,因為我只附加了一個 MWE,并忽略了代碼中有問題的部分。


這是導致我的問題的 CSS 部分:


#bar-graph tbody tr {

    height: 296px;

    padding-top: 2px;

}

感謝大家的見解


查看完整回答
反對 回復 2023-10-24
  • 1 回答
  • 0 關注
  • 99 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號