2016-01-13 43 views
1

enter image description here如何在joomla输入内添加按钮

这就是我的输入和按钮的样子。 CSS代码如下所示:

button._searchfrontpage 
{ 

margin: 0 auto; 
    background: #333; 
     height: 53px; 
     width: 70px; 
     border-radius: 6px; 
     line-height: normal; 
     color: #eee;  
     font-weight: 400; 
     letter-spacing: 2px; 
     border: 0px; 
     display: block; 
     font-size: 18px; 


} 

.sp-module_searchfrontpage input[type="text"] { 


     background: #f0dbc5; 
     height: 53px; 
     width: 50%; 
     margin: 0 auto; 
     border-radius: 6px; 
     margin-bottom: 40px; 
     line-height: normal; 
     color: #444;  
     font-weight: 400; 
     letter-spacing: 2px; 
     border: 0px; 
     display: block; 


} 

我不似乎想出一个办法来拖动灰色按钮进入我的输入框的右侧。有没有人可以想到我的想法?

编辑:执行代码之后@Jai给了我,它看起来不错,但是当我让浏览器更小,它得到了它的地方,看起来像这样:

enter image description here

显然它像那是因为输入宽度是50%。有没有解决方案?

回答

2

为了您的div:

.sp-module_searchfrontpage{ 
     /* other CSS as is*/ 
     position: relative; 
} 

现在按钮:

button._searchfrontpage { 
     background: #333; 
     height: 53px; 
     width: 70px; 
     border-radius: 6px; 
     line-height: normal; 
     color: #eee;  
     font-weight: 400; 
     letter-spacing: 2px; 
     border: 0px; 
     display: block; 
     font-size: 18px; 
     /* add these properties */ 
     position: absolute; 
     top:0; 
     right:0; 
     z-index:100; /* <=====choose the correct value*/ 
} 

但你必须确保父div有相同的高度输入和按钮也和相对定位。

如果是不可能的,那么你可以用它们植入另一格或更好地与标签和风格与信号输入和按钮,但股利仍然需要相对位置和按钮应该被绝对定位的高度相同属性。我将与标签做到这一点:

<label> 
    <input type="text" /> 
    <button>search</button> 
</label> 

然后在CSS:

.sp-module_searchfrontpage label{ 
    width: 100%; 
    height: 53px; 
    position: relative; 
} 


    button._searchfrontpage { 
     background: #333; 
     height: 53px; 
     width: 70px; 
     border-radius: 6px; 
     line-height: normal; 
     color: #eee;  
     font-weight: 400; 
     letter-spacing: 2px; 
     border: 0px; 
     display: block; 
     font-size: 18px; 
     /* add these properties */ 
     position: absolute; 
     top:0; 
     right:0; 
     z-index:100; /* <=====choose the correct value*/ 
} 
+0

哎@Jai。感谢您的回复。我不知道为什么,由于某种原因,顶部和右侧不起作用。但不知何故输入和按钮是在同一条线上,但是,如果正确的是0,那么该按钮是向右侧,并且如果合适的是1,那么该按钮是一路到屏幕的左侧。我不知道它为什么这样做? – Peter

+0

@Peter看到0是有效的,但其他值应该与px一起分配。所以这应该是1px的不是1 – Jai

+0

感谢我的请求检查的第一篇文章,我有截图编辑它,你知道,除了改变“宽”我从输入%至固定像素任何修复? – Peter