admin管理员组文章数量:1356227
import React, { useState } from 'react';
import "./styles/input.css";
import { CiSearch } from 'react-icons/ci';
interface SearchProps {
isMobile: boolean;
onSearch?: (query: string) => void;
}
const Search: React.FC<SearchProps> = ({ isMobile, onSearch = () => {} }) => {
const [searchQuery, setSearchQuery] = useState('');
const [isFocused, setIsFocused] = useState(false);
const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value);
};
const handleSearchSubmit = (e: React.FormEvent) => {
e.preventDefault();
onSearch(searchQuery);
};
const handleFocus = (e) => {
setIsFocused(true);
console.log('Focused');
};
const handleBlur = () => {
setIsFocused(false);
console.log('Blurred');
};
const borderClass = isFocused ? 'border-b-2 border-main_theme' : 'border-b border-gray-300';
// console.log('Applied class:', borderClass);
return (
<form onSubmit={handleSearchSubmit} className="relative w-[350px] lg:w-[500px]">
<div className={`flex items-center`}>
<input
type="text"
placeholder="Поиск"
className="w-full p-2 border-none"
value={searchQuery}
onChange={handleSearchChange}
onFocus={handleFocus}
onBlur={handleBlur}
/>
<button
type="submit"
className="p-2 text-gray-400 focus:outline-hidden"
>
<CiSearch className="h-5 w-5" />
</button>
</div>
<hr className={`${borderClass}`} />
</form>
);
};
export default Search;
This is my code, the problem occurs with an input element, tried to style it both with Tailwind CSS, inline styles and additional css as in example, but none of variants helped(additional styling for it below) -
input.css
input {
outline: none;
border: none;
box-shadow: none;
}
input:focus {
outline: none;
border-bottom: none;
}
For some reason after all corrections and additions I get this result when focused(screen). Meanwhile I need to completely remove an outline while focused
import React, { useState } from 'react';
import "./styles/input.css";
import { CiSearch } from 'react-icons/ci';
interface SearchProps {
isMobile: boolean;
onSearch?: (query: string) => void;
}
const Search: React.FC<SearchProps> = ({ isMobile, onSearch = () => {} }) => {
const [searchQuery, setSearchQuery] = useState('');
const [isFocused, setIsFocused] = useState(false);
const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value);
};
const handleSearchSubmit = (e: React.FormEvent) => {
e.preventDefault();
onSearch(searchQuery);
};
const handleFocus = (e) => {
setIsFocused(true);
console.log('Focused');
};
const handleBlur = () => {
setIsFocused(false);
console.log('Blurred');
};
const borderClass = isFocused ? 'border-b-2 border-main_theme' : 'border-b border-gray-300';
// console.log('Applied class:', borderClass);
return (
<form onSubmit={handleSearchSubmit} className="relative w-[350px] lg:w-[500px]">
<div className={`flex items-center`}>
<input
type="text"
placeholder="Поиск"
className="w-full p-2 border-none"
value={searchQuery}
onChange={handleSearchChange}
onFocus={handleFocus}
onBlur={handleBlur}
/>
<button
type="submit"
className="p-2 text-gray-400 focus:outline-hidden"
>
<CiSearch className="h-5 w-5" />
</button>
</div>
<hr className={`${borderClass}`} />
</form>
);
};
export default Search;
This is my code, the problem occurs with an input element, tried to style it both with Tailwind CSS, inline styles and additional css as in example, but none of variants helped(additional styling for it below) -
input.css
input {
outline: none;
border: none;
box-shadow: none;
}
input:focus {
outline: none;
border-bottom: none;
}
For some reason after all corrections and additions I get this result when focused(screen). Meanwhile I need to completely remove an outline while focused
Share Improve this question edited Mar 30 at 23:47 Phil 165k25 gold badges262 silver badges267 bronze badges asked Mar 30 at 23:34 bashlykov bashlykov 13 bronze badges 3 |1 Answer
Reset to default -1input {
outline: none !important;
border: none !important;
box-shadow: none !important;
}
input:focus {
outline: none !important;
border-bottom: none !important;
}
Such modification of module css file helped resolvnig the situation.
本文标签: javascriptCannot remove outline in inputStack Overflow
版权声明:本文标题:javascript - Cannot remove outline in input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743971995a2570728.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
!important
? – Periplo Commented Mar 31 at 4:10