html调整div上下顺序,用了float后div块之间的上下顺序不对了_html/css_WEB-ITnose

本文探讨了在CSS布局中遇到的一个问题,即在设置`margin-top`属性试图在两个`input`元素间创建间距时无效。解决方案是通过浮动元素并调整`margin-top`来实现所需间距。作者建议避免过度使用层和复杂样式,保持HTML结构简洁。此外,还提供了快速修复代码示例。
摘要由CSDN通过智能技术生成

先看代码

username_06.jpg

password_09.jpg

#formpanel{width:341px;height:135px;margin-left:auto;margin-right:auto;}#username_field{margin-top:0px;width:340px;}#usernamepic{float:left;margin-top:0px;margin-left:0px;}#inputfield{float:right;margin-top:0px;margin-right:0px;width:228px;height:27px;}#password_field{width:340px;}

现在出现的问题是我想出现这样的结果

但是却出现了这样的结果

我在password中设置margin-top却不管用,这是为什么?我想在两个input中间空出24个像素。

回复讨论(解决方案)

#password_field{

margin-top:10px;

width:340px;

}

username_06.jpg

password_09.jpg

最快的方法就是:

#password_field{

float:right;

width:340px;

margin-top:24px;

}

希望对你有帮助,欢迎回访!!

用户名同密码一样的布局为什么还要两个不同层,增加无谓的样式,

用户名:

密码:

简单东西不要复杂化,html上面的足矣。

声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理

您好!以下是CSS3实现蒲公英飘动效果和云朵飘动效果的示例代码: ## 蒲公英飘动效果 ```html <div class="dandelion"> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="puff"></div> </div> ``` ```css .dandelion { position: relative; width: 100px; height: 100px; } .petal { position: absolute; width: 5px; height: 20px; border-radius: 5px; background-color: #f4d2a9; transform-origin: bottom center; animation-name: petal-float; animation-duration: 3s; animation-iteration-count: infinite; } .petal:nth-child(1) { left: 20%; transform: rotate(30deg); animation-delay: 0.2s; } .petal:nth-child(2) { left: 40%; transform: rotate(-30deg); animation-delay: 0.3s; } .petal:nth-child(3) { left: 60%; transform: rotate(30deg); animation-delay: 0.4s; } .petal:nth-child(4) { left: 80%; transform: rotate(-30deg); animation-delay: 0.5s; } .petal:nth-child(5) { left: 50%; transform: rotate(0deg); animation-delay: 0.6s; } .puff { position: absolute; bottom: 0; left: 40%; width: 20px; height: 20px; border-radius: 50%; background-color: #fff; box-shadow: 0 0 10px #fff; animation-name: puff-float; animation-duration: 3s; animation-iteration-count: infinite; } @keyframes petal-float { 0% { transform: translateY(0); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0); } } @keyframes puff-float { 0% { transform: translateY(0); } 50% { transform: translateY(-5px); } 100% { transform: translateY(0); } } ``` ## 云朵飘动效果 ```html <div class="cloud"></div> ``` ```css .cloud { position: absolute; top: 50px; left: -100px; width: 150px; height: 80px; border-radius: 50px; background-color: #fff; box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3); animation-name: cloud-float; animation-duration: 10s; animation-iteration-count: infinite; } @keyframes cloud-float { 0% { transform: translateX(-100px); } 50% { transform: translateX(300px); } 100% { transform: translateX(-100px); } } ``` 希望对您有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值