html - 如何将样式应用于 HTML element?</h1>
<div id="body"><p>My question is simple, I just want to know that is there any way to apply CSS style to HTML element. Like the following declaration:</p>
<pre><code>title{
col
问题描述
解决方案
不,没有办法为这个元素设置样式,因为它是由浏览器和用户控制的。在查看页面时,您唯一可以对标题做的事情就是更改它,但保持在同一页面上:
function changeTitle() {
document.title = "Title Changed!";
document.getElementById('test').innerHTML = "Title has been changed!";
}
<button onclick="changeTitle()">Click Me!</button>
<p id="test"></p>
<p>View source to see the effect!</p>
抱歉缺少<title>
样式,但就是这样。也许在 CSS4 中,他们可能会改变它。但是,我对此表示怀疑。
推荐阅读
- python - 这可能吗:将虚拟环境克隆到每个用户的笔记本电脑,而源代码和相关文件保留在网络驱动器中
- c++ - 如何在 winApi 上正确创建按钮并处理其消息
- python - 如何在 kivy 中的形状之间添加填充?
- android-10.0 - Android Q Edge to Edge 应用内容不显示透明导航栏
- java - restTemplate.getForObject 上的 HttpClientErrorException
- c# - 如何在 C# 中压缩我的世界块?
- oracle - 带有Oracle的PHP PDO,当输出参数是游标时调用存储过程
- php - Laravel:不允许序列化 'Illuminate\Http\UploadedFile'
- django - DatabaseError:无法在 django 上打开数据库文件
- cypress - 如何在测试运行之前存根在 html 上定义的变量