html - 我需要将我创建的标签放在文本框中/或文本框旁边。有什么想法吗?

标签 html css

我有以下代码,现在我陷入了如何将标签放入文本框/文本框旁边以给出 1 个元素的感知的困境:

HTML

<div style="position: relative; float: left;  margin-left: 12px;">
    <input type="text" class="theInput" />
    <label class="theLabel">$    &nbsp;  |</label>
</div>

CSS

.theInput {
    -webkit-appearance: none;
    -moz-appearance: none;
    text-overflow: ellipsis;
    color: #333333; 
    outline: none;
    border: 1px solid #E4EBED;
    border-radius: 3px;
    width: 70px;
    height: 32px;
    line-height: 25px;
    font-size: 16px;
    vertical-align: middle;
    background-color: #fff; 
    padding-left:45px;

}


.theLabel {
    position:absolute;
    z-index:999;
    -webkit-appearance: none;
    -moz-appearance: none; 
    color: #333333; 
    outline: none; 
    width: 34px;
    height: 32px;
    line-height: 30px;
    font-size: 20px; 
    background-color: #fff; 
    margin-left:-106px; 
    font-weight: bold;
    cursor:default;
}

这是所需的:final result

最佳答案

示例如下:

http://jsfiddle.net/d5ca4z88/

您应该像这样使用标签标签:

<label>Label Name: <input type="text" class="theInput"></label>

关于html - 我需要将我创建的标签放在文本框中/或文本框旁边。有什么想法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33518186/

相关文章:

悬停时 JQuery 更改 img src 不起作用

jquery - D3.js 仅在一行上绘制条形图矩形

html - 如何在服务器中存储大量图像以便于在html页面中检索?

javascript - 对 h1、h2 标题、重置计数器的嵌套文档进行编号

css - 使用 Bourbon 在单个元素上添加多个框阴影

jquery - jQuery slidein 背景问题

html - 图像缩放问题(尺寸缩小质量损失)

javascript - 页面错误($.plot 不是函数)

html - 并排放置元素

CSS 背景图像太大