我試圖將搜尋框向左擴展,但不知何故它佔用了寬度並向右擴展。我嘗試給左邊距但仍然不起作用。
這裡它向右擴展,但我希望它向左擴展。我嘗試添加左側填充,但它在框內而不是在框外受到影響。
.search-click { border: 1px solid #ccc; outline: none; background-size: 22px; background-position: 13px; border-radius: 100px; width: 363px; height: 40px; padding: 21px; transition: all 0.5s; margin-top: 54px; text-overflow: ellipsis; position: relative; overflow: hidden; //margin-left: -410px; } .search-click:focus { width: 800px; padding-left: 20px; } .search-click input { background: transparent; border: 1px solid #ccc; outline: none; position: absolute; width: 300px; height: 50px; left: 0%; padding: 10px; }
<input type="text" class="search-click" placeholder="Search ports, countries, international code port" />
P粉9472963252024-02-27 11:43:47
對於左側的寬度過渡,我已將輸入的位置變更為右側。更改了 position:absolute
和 right:0;頂部:0
。
.search-click { border: 1px solid #ccc; outline: none; background-size: 22px; background-position: 13px; border-radius: 100px; width: 100px; padding: 21px; transition: all 0.5s; text-overflow: ellipsis; position: relative; overflow: hidden; text-align: left; position: absolute; right: 0; top: 0; margin: 1em; } .search-click:focus { width: 400px; padding-left: 20px; }#