bootstrap button 按钮靠右布局

5 篇文章 0 订阅
容器下的button居右问题
<div style="border:1px black solid;width:500px;height:500px;">
<input style="float:right" type="button" value="click me!" />
</div>

<div style="border:1px black solid;width:500px;height:500px;text-align:right">
<input type="button" value="click me!" />
</div>

可以给 button 增加样式 float:right;
也可以给父div 增加样式 text-align:right;

原文地址:https://bbs.csdn.net/topics/390188760

  • 16
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是一个简单的HTML页面,实现了你的要求: ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>文件实验室/账号登录</title> <style> body { font-family: "楷体", KaiTi, serif; margin: 0; padding: 0; } .container { display: flex; flex-direction: row; justify-content: space-between; align-items: center; height: 100vh; box-sizing: border-box; padding: 1em; } .form { display: flex; flex-direction: column; align-items: flex-end; width: 40%; max-width: 500px; } label { display: block; margin-bottom: 0.5em; } input { margin-bottom: 1em; padding: 0.5em; font-size: 1em; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box; width: 100%; max-width: 300px; } button { padding: 0.5em 1em; font-size: 1em; border: none; border-radius: 5px; background-color: #007bff; color: #fff; cursor: pointer; } button:disabled { background-color: #ccc; cursor: not-allowed; } </style> </head> <body> <div class="container"> <form class="form"> <label for="email">输入接收验证码的邮箱</label> <input type="email" id="email" name="email" required> <button type="button" id="get-code">获取验证码</button> <label for="code">输入验证码</label> <input type="text" id="code" name="code" required> <button type="submit" id="login">登录</button> </form> </div> <script> var getCodeBtn = document.getElementById('get-code'); var countdown = 60; var countdownTimer; getCodeBtn.addEventListener('click', function() { getCodeBtn.disabled = true; countdownTimer = setInterval(function() { countdown--; getCodeBtn.textContent = countdown + '秒后再试'; if (countdown <= 0) { clearInterval(countdownTimer); countdown = 60; getCodeBtn.textContent = '获取验证码'; getCodeBtn.disabled = false; } }, 1000); // 使用ajax发送请求 var xhr = new XMLHttpRequest(); xhr.open('POST', '/admin/'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('email=' + encodeURIComponent(document.getElementById('email').value)); }); document.getElementById('login').addEventListener('click', function(e) { e.preventDefault(); // 使用ajax发送请求 var xhr = new XMLHttpRequest(); xhr.open('POST', '/response/'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { if (xhr.status === 200) { if (xhr.responseText === 'success') { window.location.href = 'https://www.spacexs.cn'; } else { alert('验证码错误,请重新输入!'); } } }; xhr.send('code=' + encodeURIComponent(document.getElementById('code').value)); }); </script> </body> </html> ``` 这个页面使用了Flexbox布局,实现了左右布局,输入框、按钮靠右边,并且能够自适应PC和手机页面。使用了ajax技术发送请求,实现了获取验证码和登录功能。获取验证码按钮在点击后会进入倒计时状态,60秒后才能再次点击。在登录时,使用ajax发送请求到后端验证验证码,验证通过则跳转到指定页面,验证失败则要求重新输入。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值