【发布时间】:2021-05-14 00:51:34
【问题描述】:
我有一个输入字段,其中包含输入字段右侧的 svg 图像。但实际上,当我在输入字段中输入内容并且输入到达图像时,输入会溢出我的图像。有什么办法可以防止输入溢出我的图像,以便我的输入字段在图像之前“停止”几个 px?我想用顺风在 vue 中做所有事情。
到目前为止我的代码:
<div
class="flex relative w-500px h-48px group justify-center items-center z-1001 pl-8">
<input
v-model="input"
type="text"
placeholder="Input..."
class="flex h-48px w-500x px-3 py-3 placeholder-gray-600 text-black text-18px flex-none border border-transparent rounded focus:border-gray-400 outline-none"
/>
<span
class="flex absolute right-0 bg-transparent rounded text-base text-gray-600"
>
<svg
class="fill-current"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
...
</svg>
</span>
整个东西应该是这样的:
【问题讨论】:
-
您可以尝试在输入字段中添加
padding-right等于SVG 的宽度,然后提供图像position: absolute; right: 0。 -
抱歉,我应该完整阅读您的代码 - 我想您需要做的唯一更改是在输入字段中添加一个
pr-类并给它一个接近宽度的值SVG 的。
标签: css image input tailwind-css