input {
  width: 100%;
}

.input-currency:after {
  position: absolute;
  right: 0;
  top: 10px;
  content: 'USD';
  border-left: 1px solid black;
  padding: 0 7px;
  padding-right: 4em;
}
<div class="input-currency">
  <input id="value" name="value" type="text" class="form-control m-input class" aria-describedby="basic-addon1">
</div>

我有这样一个输入字段:

<div class="input-currency">
  <input id="value" name="value" type="text" class="form-control m-input class" aria-describedby="basic-addon1">
</div>

我在输入的右侧添加了货币文本:

input {
  width: 100%;
}

.input-currency:after {
  position: absolute;
  right: 0;
  top: 10px;
  content: 'USD';
  border-left: 1px solid black;
  padding: 0 7px;
  padding-right: 4em;
}

现在,我想在输入的右侧为其他货币文本添加一个 Select 选项,当我单击"USD"文本时,它将显示其他选项,如"EUR",...但是布局css将与我以前的css相同,只有一条竖线和文本,其他什么都没有.

我必须使用select选项,因为我想在提交表单以将其保存到数据库时获取此货币值.

你能帮助我吗?

非常感谢你!

推荐答案

Put your input and select tags in a container, remove the default styling from both, and then add a border (or outline if you prefer) to the container itself.

input {
  width: 80vw;
  outline: none;
  border: none;
}

select {
  width: 20vw;
  outline: none;
  border: none;
}

.inputContainer {
  display: flex;
  flex-direction: row;
  gap: 2px;
  border: 1px solid black;
}
<div class="inputContainer">
  <input id="value" name="value" type="text" class="form-control m-input class" aria-describedby="basic-addon1">
  <select>
    <option value="USD">USD</option>
    <option value="EUR">EUR</option>
  </select>
</div>

Html相关问答推荐

卸载伪元素 destruct 了CSS

如何实现弯曲的梯形导航栏?

悬停效果在新西兰表上不起作用

如何更改Django中的默认按钮?

CSS中的转换属性是如何工作的?

div居中碰撞问题

为什么字体大小而不是 colored颜色 属性适用于元素?

HTML 重定向到当前服务器

文本不显示在 div 下方

网页爬虫:使用时光机器进行数据采集

拨动switch 在重新加载时未重置

如何截断一些文本并用双引号引起来?

透明渐变凹矩形

我应该如何使这个带有标签的隐藏复选框可访问

提交前的验证表单未显示任何验证消息?

Header 或 P 标记中的填充不能与 em 单元一起正常工作

CSS 斜角与 3 行对齐

让 Bootstrap 5 模式和背景占据父容器的宽度和高度,而不是全屏

focusout() Select 器不适用于搜索框

如何使用 :hover zoom 重叠图像?