css - 定位一个CSS按钮

标签 css html

我想让一个按钮出现在下一行。但是我尝试使用按钮的属性“位置”和“行高”但没有任何改变。我希望它位于 tne name 输入文本下的下一行的中心 the button i want to move it to the next line

这是我的代码:

CSS文件:

#popup {
font-family: 'Orbitron', serif;
font-size: 28px;
font-weight: 700;     
text-shadow: 0px 1px 2px #fff;

color: #222;

position: absolute;   
width: 100%;
height: 100%;
top: 0;
left: 0;

background: rgba(0,0,0,.5);

display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;          

-webkit-transition: all .5s ease-in;}

   #popup h1 {
font-weight: 400;
   }

   #popup-box {
width: 400px;
height: 300px;
background: #ccc url(../images/popup_bg.jpg);

border-radius: 10px;

position: relative;

-webkit-box-shadow: 0 5px 5px #333;

display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;

-webkit-transition: all .5s ease-in;}

    #popup-box small {
font-size: .6em; }


   #popup.hide {
background: rgba(0,0,0,0);
visibility: hidden;     
    }
     #popup.hide #popup-box{
margin-top: -800px;}


  #popup-box a.button {
background: white;
border-radius: 10px;
display: block;
font-size: 30px;
margin: 230px auto 0;
padding: 10px;
width: 50px;
border: 3px solid #006438;
color:#006438;
text-decoration:none;
cursor:pointer;}

html文件:

<section id="popup">
    <div id="popup-bg">
    </div>
 <div id="popup-box">   
 <p><a id="gamelogin1" class="button"   href="">choose Name</a></p>
 <p><a id="gamelogin2" class="button"   href="">New Name</a></p>
 </div>
</section>

<section id="popupName" class="hide">
   <div id="popup-bg">
    </div>
 <div id="popup-box">   
 <label for="firstName">Your Name :</label>
<input type="text" name="firstName" size="20" maxlength="40"  id="firstName" />

 **<p><a id="validatelogin" class="button"  href="">Validate</a></p> //this is the //button i want to change**
</div>
</section>

最佳答案

在输入字段后添加换行符 ( <br>):

<input type="text" name="firstName" size="20" maxlength="40"  id="firstName" /><br>

有些人会争辩说 <br>标签应该自动关闭:<br /> ,但这不是必需的。

要使其居中,请使用此 CSS:

#validatelogin {
    width:100px;
    margin: 0 auto;
}

设置宽度为按钮合适的宽度;为了 margin: 0 auto; 必须修复它去工作。

关于css - 定位一个CSS按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10286866/

相关文章:

jquery - 通过单击并拖动来导航窗口

css - 移动网页的最佳字体大小

html - 样式在 iOS 手机差距应用程序中无法正确显示

javascript - 如何使信息框在点击时出现在网站上

javascript - 覆盖 Twitter Bootstrap 3's radio group "onclick“事件

html - 相对于占用父级其余宽度的文本垂直居中图像?

asp.net - asp.net 控件之前 html 中奇怪的 ""引号

html - 开发现代 J2ME 应用程序的最佳方式是什么?

PHP html DOM 对比纯 HTML 速度

html - 圆形百分比进度条