Skip to main content
基本 Svelte
介绍
反应性
属性
逻辑
事件
绑定
类和样式
动作
转换
高级 Svelte
高级反应性
重用内容
运动
高级绑定
高级转换
上下文 API
特殊元素
<script module>
后续步骤
基本 SvelteKit
介绍
路由
加载数据
标题和 cookie
共享模块
表单
API 路由
$app/state
错误和重定向
高级 SvelteKit
钩子
页面选项
链接选项
高级路由
高级加载
环境变量
结论

就像在 HTML 中一样,你可以向组件添加 <style> 标签。让我们为 <p> 元素添加一些样式:

¥Just like in HTML, you can add a <style> tag to your component. Let’s add some styles to the <p> element:

App
<p>This is a paragraph.</p>

<style>
	p {
		color: goldenrod;
		font-family: 'Comic Sans MS', cursive;
		font-size: 2em;
	}
</style>

重要的是,这些规则的作用域是组件。你不会意外更改应用中其他地方的 <p> 元素的样式,我们将在下一步中看到。

¥Importantly, these rules are scoped to the component. You won’t accidentally change the style of <p> elements elsewhere in your app, as we’ll see in the next step.

上一页 下一页
1
2
3
4
5
6
<p>This is a paragraph.</p>
 
<style>
	/* Write your CSS here */
</style>