两个div并列,一个响应式

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

我有以下的html和css。

我想让div class="webpushPowered "有一个响应的宽度,最小宽度为35px。我希望能响应按钮的大小。

基本上,我希望div class="webpushPowered "能根据div class="webpushButtons "的宽度进行调整,如果按钮内有更多或更少的文本,则可以增加或减少宽度。

我只使用HTML和CSS,没有外部代码.这段代码是桌面版的,我的问题是在手机上,所以请调整大小,这样你就可以看到我在说什么。

我附上的图片是这段代码在三星Galaxy S6上的效果。

这是移动端结果的图片

谢谢你!我有以下html和css。

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: none !important;
  margin: 0;
}

.webPushIframe {
  position: absolute;
  z-index: 999999999;
  display: block;
  border: none;
  background-color: transparent;
  width: 100%;
  max-width: 450px;
  min-width: 320px;
  min-height: 130px;
  height: 100%;
}

.webPushSolicitation {
  max-width: 450px;
  min-width: 350px;
  min-height: 130px;
  background: none;
  border: 0 !important;
  box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.06) !important;
  -webkit-box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.06) !important;
}

.webPushSolicitation .webPushContainner {
}

.webPushSolicitation .webPushContainner .webPushImage {
  width: 85px;
  height: 85px;
  display: block;
  float: left;
  text-align: center;
}

.webPushSolicitation .webPushContainner .webPushImage img {
  width: 65px;
  margin: 20px;
}

.webPushSolicitation .webPushContainner .webPushTexts {
  display: block;
  float: right;
  max-width: 320px;
  min-width: 320px;
  padding: 20px 20px 0 0;
}

.webPushSolicitation .webPushContainner .webPushTexts .webPushTitle {
  font-weight: 700;
  font-weight: bold;
  margin-bottom: 10px;
}

.webPushSolicitation .webPushContainner .webPushTexts .webPushText {
  word-break: break-word;
  margin-right:10px;
  max-height: 62px;
  overflow: hidden;
}

.webPushSolicitation .webPushContainner .webPushPowered {
  width: 80px;
  height: 10px;
  display: block;
  float: left;
  font-size: 9px;
  margin-top: 28px;
  margin-left: 18px;
}

.webPushSolicitation .webPushContainner .webPushPowered a,
.webPushSolicitation .webPushContainner .webPushPowered a:link,
.webPushSolicitation .webPushContainner .webPushPowered a:hover,
.webPushSolicitation .webPushContainner .webPushPowered a:visited,
.webPushSolicitation .webPushContainner .webPushPowered a:active {
  font-size: xx-small;
  text-decoration: none;
}

.webPushSolicitation .webPushContainner .webPushPowered img {
  width: 80px;
  margin: 25px 20px 20px 20px;
}

.webPushSolicitation .webPushContainner .webPushButtons {
  display: block;
  float: right;
  margin: 20px;
}

.webPushSolicitation .webPushContainner .webPushButtons .confirm,
.webPushSolicitation .webPushContainner .webPushButtons .deny {
  border-radius: 3px;
  padding: 6px 10px;
  display: block;
  float: right;
  margin-left: 5px;
  cursor: pointer;
}

.webPushConfirmation {
  max-width: 450px;
  min-width: 160px;
  background: none;
  border: 0 !important;
  box-shadow: 0 0 7px 2px rgba(0, 0, 0, 0.25) !important;
  -webkit-box-shadow: 0 0 7px 2px rgba(0, 0, 0, 0.25) !important;
}

.webPushConfirmation .webPushConfirmationImage {
  text-align: center;
  padding: 50px 0;
}

.webPushConfirmation .webPushConfirmationImage img {
  max-width: 400px;
  max-height: 100px;
}

.webPushConfirmation .webPushConfirmationTexts {
  display: block;
  text-align: center;
  padding: 10px;
}

.webPushConfirmation .webPushConfirmationTexts .webPushConfirmationTitle {
  font-weight: bold;
  margin-bottom: 10px;
}

.webPushConfirmation .webPushConfirmationPowered {
  text-align: center;
  display: block;
  padding: 20px 0;
}

.webPushConfirmation .webPushContainner .webPushConfirmationPowered img {
  width: 80px;
}

@media (max-width: 430px) {
  .webPushIframe {
    min-height: 250px;
  }
  .webPushSolicitation .webPushContainner .webPushImage {
    width: 100%;
  }
  .webPushSolicitation .webPushContainner .webPushTexts {
    max-width: 100%;
    padding: 20px 10px;
  }
}
<!DOCTYPE html><html lang="en"><head>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="https://dev-egoiapp2.com/wp/css/wp.css">
        <title>WebPush App</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    </head>
    <body>
        <div class="webPushSolicitation">
            <div class="webPushContainner" style="background-color: #F3F3F3;">
                <div class="webPushImage">
                    <img src="https://egoiapp2.com/img/default-pushicon.png">
                </div>
                <div class="webPushTexts">
                    <div class="webPushTitle" style="color: #364656;">Novidades? Nós avisamos!</div>
                    <div class="webPushText" style="color: #364656;">Sempre que tivermos coisas novas para si, vai ver uma mensagenzinha no seu ecrã :)</div>
                    <input type="email" placeholder="E-mail" id="email" name="email" style="display:none;">

                </div>
                <div style="clear: both; margin-top: 5px"></div>
                <div>
                <div class="webPushPowered" style="color: #364656;">
                    <a href="https://google.pt" target="_blank" style="color: #364656;">
                        Powered by <b>test</b>
                    </a>
                </div>
                <div class="webPushButtons">
                    <div class="deny" style="color: #F0F0F0; background-color: #364656;" onclick="webPush.denyNotification();" href="#">Agora não</div>
                    <div class="confirm" style="color: #F0F0F0; background-color: #00AEDA;" onclick="webPush.openAuthorizePopUp();" href="#">Quero receber alertas!</div>
                </div>
                </div>
                <div style="clear: both"></div>
            </div>
        </div>
    
</body></html>
html css mobile flexbox frontend
1个回答
0
投票

发生这种情况是因为 margin: 20px.webPushSolicitation .webPushContainner .webPushButtons. 您可以设置 margin-left: 0例如

© www.soinside.com 2019 - 2024. All rights reserved.