gpt4 book ai didi

css - html css 有点工作但实现困惑

转载 作者:太空宇宙 更新时间:2023-11-04 05:56:38 25 4
gpt4 key购买 nike

我在 wordpress 中创建了这个页脚,它基本上可以工作,但代码很丑而且结构不合理。我对 anchor 标签中的图像和文本有很多问题。此外,当浏览器宽度变得非常小时,元素不会正确落在页面上。电子邮件输入在绿色背景下方结束,在 wordpress 中, anchor 标记中的图标/文本分为两行。

我如何使它工作并看起来更干净以便更易于维护?

注意:存在媒体查询是因为需要使用这种方法对 wordpress 插件进行一些逆向工程。在不同 block 周围的 html 背景颜色白色方面遇到问题

.myfooter{
height:auto;
background-color:white;
padding: 0 2.87rem;
}

@media screen and (max-width: 961px) {.myfooter{
padding:0 1.7rem;}
}

.cap{
background-color:#538231;
}



.left input, .left label {
display:inline-block;
margin-left:3vw;
width:27vw;
font-size:1vw;
}

.left input{
height:1vw;
}

.left label{
color:#c2d59b;
padding-bottom:.5vw;
}

.left{
width:50%;
float:left;
background-color:#538231;
height:5vw;
padding-top:2vw;
padding-bottom:5vw;
}

.myfooter h1{
color:#b3d7f8; /*#b6dde6;*/
font-size:1.5vw;
text-align:left;
margin:0;
margin-left:3vw;
padding-top:2vw;

}

.right-div{
width:40%;
float:right;
color:white;
background-color:#538231;
font-size:1vw;
padding-left:10%;
height:12vw;

}

.right-div div p a {
text-decoration:none;
}

.right-div div p a:visited{
color:white;
}


.last3{
width:17vw;
margin:0 !important;
padding:0!important;
background-color:#538231;
border:solid 1px white;
margin-bottom:1vw!important;
}

.d3 p a{
display:block;
height:1.9635vw;
}

.footer-icons {
padding: .25vw;
width: 1.25vw;
text-align: center;
text-decoration: none;
margin: 0;
margin-left:.5vw;
float:left;
}

.footer-icons:hover {
opacity: 0.7;
}

.footer-txt{
padding: .5vw 0 .5vw .5vw;
font-size:1vw;
line-height:1;
float:left;
}


.submit-button {
background-color: white!important; /* Green */
border: none!important;
color: black!important;
padding: .5vw .5vw!important;
text-align: center!important;
text-decoration: none!important;
display: inline-block!important;
font-size: 1vw!important;
height:2vw!important;
width:5vw!important;
line-height:1vw!important;
}

#email{
padding:.5vw;
}
<div class="myfooter">
<div class="cap"><h1>Help create a sustainable and healthy town of Weston</h1>
</div>
<div class="left">
<form name="message" method="post">
<section>
<div style="float:left;">
<label for="email">Join our mailing list:</label>
<input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</div>
</section>
</form>
</div>
<div class="right-div">
<div class="d3">
<p class="last3">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="footer-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png">
<span class="footer-txt">Like us on Facebook</span>
</a>
</p>
</div>
<div class="d3">
<p class="last3">
<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="footer-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png">
<span class="footer-txt">follow us on Instagram</span>
</a>
</p>
</div>
<div class="d3">
<p id="4" class="last3">
<a href="https://twitter.com/Weston_SWAG">
<img class="footer-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png">
<span class="footer-txt">Retweet us on Twitter</span>
</a>
</p>
</div>
</div>
<div>

最佳答案

你为什么不尝试使用 flexbox。我删除/压缩了你的代码。当然,如果您使用 SASS,您可以将所有 CSS 包装在您的 myFooter 类中。

<div class="myFooter">
<div class="left">
<h3>Help create a sustainable and healthy town of Weston</h3>
<form name="message" method="post">
<section>
<label for="email">Join our mailing list:</label><input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</section>
</form>
</div>
<div class="right">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png"><span class="foot-txt">Like us on Facebook</span>
</a>

<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png
"><span class="foot-txt">follow us on Instagram</span>
</a>

<a href="https://twitter.com/Weston_SWAG">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png"><span class="foot-txt">Retweet us on Twitter</span>
</a>
</div>
</div>

.myFooter{
background: #538231;
padding: 1.5em;
display: flex;
flex-wrap: wrap;
}

.myFooter .left{
flex: 1 1 auto;
}

.myFooter .right{
flex: 1 1 auto;
}

.myFooter h3{
color:#b3d7f8;
font-size: 16px;
padding-bottom: 20px;
}

.myFooter label{
display: block;
color: #c2d59b
}

.myFooter input{
padding: 3px 10px;
}

.myFooter .right a{
display: block;
color: white;
border: 1px solid white;
width: 70%;
margin: 5px 0px;
}

.myFooter .right img{
width: 15px;
height: 100%;
margin: 5px 10px 5px 5px;
}

https://jsfiddle.net/wvc2p63y/

关于css - html css 有点工作但实现困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57731987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com