如果输入集中在Chrome/MS Edge中,如何禁用边框



我创建了一个输入,但在Chrome和MS Edge中,如果你点击该输入,它会在输入周围显示一个丑陋的黑色边框/框架。在Firefox中,边框/边框不会出现。如何在Chrome/MS Edge中删除此边框?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="EDT1"
style="display: block; margin: 0px; padding: 0px; position: absolute; top: 15px; left: 15px; height: 26px; min-height: 26px; max-height: 26px; width: 200px; min-width: 200px; max-width: 200px; z-index: 183; background-color: transparent; visibility: visible; border-width: 0px; border-style: solid;">
<input type="text" value="Text" title="" readonly=""
style="display: block; margin: 0px; position: absolute; height: 26px; min-height: 26px; max-height: 26px; resize: none; border-width: 0px; font-family: Arial; font-size: 12pt; line-height: 12pt; color: rgb(0, 0, 0); cursor: text; background-color: transparent; left: 0px; top: -2px; width: 194px; min-width: 194px; max-width: 194px; padding: 2px 3px 0px; text-align: left;">
</div>
</body>
</html>

请添加以下css:

input:focus{
outline: none;
}

这将删除默认值并添加一个类似于Firefox上的边框。此外,练习结构与表现的分离。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#EDT1 {
display: block; 
margin: 0px; 
padding: 0px; 
position: absolute; 
top: 15px; 
left: 15px; 
height: 26px; 
min-height: 26px; 
max-height: 26px; 
width: 200px; 
min-width: 200px; 
max-width: 200px; 
z-index: 183; 
background-color: transparent; 
visibility: visible; 
border-width: 0px; 
border-style: solid;
}
input {
display: block; 
margin: 0px; 
position: absolute; 
height: 26px; 
min-height: 26px; 
max-height: 26px; 
resize: none; 
border-width: 0px; 
font-family: Arial; 
font-size: 12pt; 
line-height: 12pt; color: rgb(0, 0, 0); 
cursor: text; 
background-color: 
transparent; 
left: 0px; 
top: -2px; 
width: 194px; 
min-width: 194px; 
max-width: 194px; 
padding: 2px 3px 0px; 
text-align: left;
}
input:focus{
outline: none;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div id="EDT1">
<input type="text" value="Text" title="" readonly="">
</div>
</body>
</html>

最新更新