gpt4 book ai didi

html - css 只显示一半的文本框?

转载 作者:行者123 更新时间:2023-11-28 16:45:18 26 4
gpt4 key购买 nike

刚从 codepen 得到这个搜索按钮,试着把它放在我的网站上,结果失败了!我一团糟,我看不出问题是什么,

发生的事情是动画播放可爱!搜索栏加载,但是打字的时候,你只能看到一半的文字,见下图

image of search

这是我的代码

$brand: #b3c33a;
$speed: 0.5s;

body {
color: $brand;
background-color: #333;
}

.search {
position: absolute;
top: 50%;
left: 50%;
margin-left: -300px;

width: 600px;
}

svg {
position: absolute;
transform: translateX(-246px);
width: 600px;
height: auto;
stroke-width: 8px;
stroke: $brand;
stroke-width: 1px;
stroke-dashoffset: 0;
stroke-dasharray: 64.6 206.305;
transition: all 0.5s ease-in-out;
stroke-linejoin: round;
stroke-linecap: round;
}

.input-search {
position: absolute;
width: calc(100% - 148px);
height: 64px;
top: 0;
right: 20px;
bottom: 0;
left: 0;
border: none;
background-color: transparent;
outline: none;
padding: 20px;
font-size: 50px;
}

.search-label {
position: absolute;
display: block;
width: 108px;
height: 108px;
top: 0;
left: 50%;
margin-left: -54px;
z-index: 100;
transition: $speed ease-in-out;
}

.isActive {
.search-label {
transform: translateX(246px);
}
svg {
stroke-dashoffset: -65;
stroke-dasharray: 141.305 65;
transform: translateX(0);
}
&.full svg {
stroke-dashoffset: -65;
stroke-dasharray: 141.305 65;
transform: translateX(0);
}
}

.full {
.search-label {
transform: translateX(246px);
}
svg {
stroke-dashoffset: 0;
stroke-dasharray: 64.6 206.305;
transform: translateX(0);
}
}
<div class="col-md-10">

<div class="search">
<svg version="1.1" viewBox="0 0 142.358 24.582">
<path id="search-path" fill="none" d="M131.597,14.529c-1.487,1.487-3.542,2.407-5.811,2.407
c-4.539,0-8.218-3.679-8.218-8.218s3.679-8.218,8.218-8.218c4.539,0,8.218,3.679,8.218,8.218
C134.004,10.987,133.084,13.042,131.597,14.529c0,0,9.554,9.554,9.554,9.554H0"/>
</svg>
<label for="search" class="search-label"></label>
<input type="search" id="search" autocomplete="off" class="input-search"/>
</div>
<script type="text/javascript">
/*
Inspired by Dribble "Search..."
By: Anish Chandran
Link: http://drbl.in/nRxe
*/

var searchField = $('.search');
var searchInput = $("input[type='search']");

var checkSearch = function(){
var contents = searchInput.val();
if(contents.length !== 0){
searchField.addClass('full');
} else {
searchField.removeClass('full');
}
};

$("input[type='search']").focus(function(){
searchField.addClass('isActive');
}).blur(function(){
searchField.removeClass('isActive');
checkSearch();
});
</script>

</div>

仅 CSS(不是 scss)

body {
color: #b3c33a;
background-color: #333;
}

.search {
position: absolute;
top: 50%;
left: 50%;
margin-left: -300px;
margin-top: -54px;
width: 600px;
}

svg {
position: absolute;
transform: translateX(-246px);
width: 600px;
height: auto;
stroke-width: 8px;
stroke: #b3c33a;
stroke-width: 1px;
stroke-dashoffset: 0;
stroke-dasharray: 64.6 206.305;
transition: all 0.5s ease-in-out;
stroke-linejoin: round;
stroke-linecap: round;
}

.input-search {
position: absolute;
width: calc(100% - 148px);
height: 64px;
top: 0;
right: 20px;
bottom: 0;
left: 0;
border: none;
background-color: transparent;
outline: none;
padding: 20px;
font-size: 50px;
}

.search-label {
position: absolute;
display: block;
width: 108px;
height: 108px;
top: 0;
left: 50%;
margin-left: -54px;
z-index: 100;
transition: 0.5s ease-in-out;
}

.isActive .search-label {
transform: translateX(246px);
}
.isActive svg {
stroke-dashoffset: -65;
stroke-dasharray: 141.305 65;
transform: translateX(0);
}
.isActive.full svg {
stroke-dashoffset: -65;
stroke-dasharray: 141.305 65;
transform: translateX(0);
}

.full .search-label {
transform: translateX(246px);
}
.full svg {
stroke-dashoffset: 0;
stroke-dasharray: 64.6 206.305;
transform: translateX(0);
}

最佳答案

这不是纯 CSS,因此无法在您的浏览器中正确输出。他们使用 SASS ( http://sass-lang.com/ ),所以如果你想使用它,你需要先将 SASS 编译成 CSS,或者寻找纯 CSS 输出(如果你从 Codepen 复制它应该可用)

关于html - css 只显示一半的文本框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33282423/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com