登录页输入框仅填充一半求助:!important无效,疑样式覆盖
width:100%!important Hey there! Let's break down why your login page inputs are only filling half the width, even with !important forcing full width. The issue isn't actually a style priority conflict—it's all about the empty <label> elements in your .input containers.
Quick Fixes
Here are two straightforward ways to fix this:
Make labels block elements
Force the empty labels to take up their own line, so the input can fill the full width of the container:.input label { display: block; }Hide empty labels entirely
Since your labels don't have any content, you can just hide them to remove their impact on the layout:.input label { display: none; }And you can even remove the
!importantfrom your input styles now—they'll work perfectly without it:.input input { width: 100%; outline: none; border: none; font-family: "Courier", monospace; }
Why This Happened
- Label's default behavior:
<label>tags are inline elements by default. Even when empty, they take up small amounts of space in the layout (from default line height or invisible whitespace). Your input is an inline-block element, so when you setwidth:100%, the browser tries to fit both the label and input in the same line—compressing the input to half the width to make room. !importantdidn't help: You used!importantthinking there was a style override, but other pages work because they don't have these empty labels. The problem was layout structure, not style priority.
Pro Tip: Ditch !important When You Can
You're right to avoid !important—it makes styles harder to maintain. Your .input input selector already has higher specificity than a generic input selector, so it will override default styles without needing !important.
内容的提问来源于stack exchange,提问作者duxthor

