我不知道如何移除这个文本区域的边框轮廓。

huangapple go评论55阅读模式
英文:

I don't know how to remove the border outline of this text area

问题

这个textarea外部有一个蓝色的轮廓线,我已经尝试在CSS中使用outline:none;,但没有生效。

以下是代码部分:

#floatingTextarea {
  border: none;
  outline: none;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<div class="form-floating container-fluid h-100 w-100">
  <textarea class="form-control text-center align-center" id="floatingTextarea" style="height:100vh;background-color:#dddddd;"></textarea>
  <label for="align-center" class="text-center"></label>

这是蓝色轮廓线的截图:这是蓝色轮廓线

我只想让它消失。我已经查看了其他关于相同问题的帖子,但似乎仍然找不到有效的解决方法。

英文:

There is a blue outline around the outside of this textarea and I have already tried to do outline:none; in css.

here the code:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

#floatingTextarea {
  border: none;
  outline: none;
}

<!-- language: lang-html -->

&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt;

&lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;form-floating container-fluid h-100 w-100&quot;&gt;
  &lt;textarea class=&quot;form-control text-center align-center&quot; id=&quot;floatingTextarea&quot; style=&quot;height:100vh;background-color:#dddddd;&quot;&gt;&lt;/textarea&gt;
  &lt;label for=&quot;align-center&quot; class=&quot;text-center&quot;&gt;&lt;/label&gt;`

<!-- end snippet -->

this is the blue outline

I just want it to go away. I have looked at other posts about the same problem but I still cant seem to find an answer that works.

答案1

得分: 1

以下是翻译好的内容:

"如果没有了解您的实际代码文件,很难说。如果可能的话,请通过 codepen 分享它。
在那之前,我将分享对我有效的解决方案,即:

#floatingTextarea {
  border: none;
  box-shadow: none;
}

或者

#floatingTextarea {
  border: none;
  outline: none !important;
}
```"

<details>
<summary>英文:</summary>

It&#39;s hard to say without knowing your actual code file.If possible please share it through codepen.
Till then I will share the solutions that worked for me which is  :

    #floatingTextarea {
      border: none;
      box-shadow: none;
    }

OR

    #floatingTextarea {
      border: none;
      outline: none !important;
    }



</details>



# 答案2
**得分**: 0

Use your inspector to check weather outline: none; border: none; is applied to the element, make sure that the properties is no being stricken out. This may happens due to multiple reason

-  CSS 规则被多次写入时位于顶部的 CSS 规则将被底部相同的 CSS 规则覆盖
- 当使用 !important 没有 !important 的属性值将被覆盖
- 当使用多个类时第一个类的属性将被最后一个类覆盖

解决您问题的即时方法是使用

`#floatingTextarea {
border: none !important;
outline: none !important;
}`

请注意通常应避免使用 !important除非绝对必要因为它很难维护代码并进行调试

<details>
<summary>英文:</summary>

Use your inspector to check weather outline: none; border: none; is applied to the element, make sure that the properties is no being stricken out. This may happens due to multiple reason 

 - when the css rule is written multiple times that is the css rule which is declared at top will be over written by the css rule with same written at the bottom

 - when !important is used then the property-values without !important will be overwritten

 - when multiple classes are used then the properties of first class will be overwritten by the latest class

The immediate solution for your problem is to use :

`#floatingTextarea {
border: none !important;
outline: none !important;
}`

&lt;em&gt;Note that using !important should generally be avoided unless absolutely necessary because it is hard to maintain the code and debug it.&lt;/em&gt;


</details>



huangapple
  • 本文由 发表于 2023年5月14日 17:56:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76246853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定