使用嵌入式CSS将图像添加到背景中

斯巴达高尔夫

我是HTML和CSS的新手。我想在页面背景上添加图片,但是我不知道该怎么做。

我想将CSS保留在页面内部,以便此背景图片由<head>页面中的CSS指定

<!DOCTYPE html>
<html>
<head>
  <h2>How to write 'Text' in 6 of coding languages </h2>
</head>
<style>
body {
 background-color: rgb(60, 60, 60);
 }

h2 {
 color: white;
 font-family: arial;
 font-size: 200%;
 }

h4 {
 color: white;
 font-family: arial;
 font-size: 165%;
 }

h6 {
 color: white;
 font-family: arial;
 font-size: 125%;
 }

p {
 color: white;
 font-family: arial;
 font-size: 100%;
 }
</style>
<body>
</body>
</html>
达克里·丹尼

您可以通过background-imageCSS属性为页面的背景设置图像在此,通过URL指定背景图像并将其应用于body文档元素:

body {
 background-color: rgb(60, 60, 60);

 /* Add this */
 background-image: url(https://www.vemco.com/wp-content/uploads/2012/09/image-banner2.jpg);
 }

这是现有HTML的完整示例:

<!DOCTYPE html>
<html>
<head>
  <h2>How to write 'Text' in 6 of coding languages </h2>
</head>
<style>
body {
 background-color: rgb(60, 60, 60);
 
 /* Add this */
 background-image: url(https://www.vemco.com/wp-content/uploads/2012/09/image-banner2.jpg);
 }

h2 {
 color: white;
 font-family: arial;
 font-size: 200%;
 }

h4 {
 color: white;
 font-family: arial;
 font-size: 165%;
 }

h6 {
 color: white;
 font-family: arial;
 font-size: 125%;
 }

p {
 color: white;
 font-family: arial;
 font-size: 100%;
 }
</style>
<body>
</body>
</html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将另一个背景图像添加到已经具有嵌入式背景图像的元素中

将字典添加到嵌入式字典

将 SharePoint 页面添加到 TFS 中的“嵌入式网页”小部件时出错

如何将下拉菜单添加到嵌入式SwiftUI NavigationBarTitle中?

将数据添加到与PostingFormats相关的Java嵌入式Elasticsearch中的索引时出错

如何将IBOutlet添加到嵌入式TableView中的类

Mongodb:将字段添加到嵌入式文档中(无数组)

要使用keytool,我应该将android studio中的嵌入式jdk添加到PATH中还是应该全局安装jdk?

Internet Explorer 9中的类型不匹配错误:将<title>添加到嵌入式SVG

通过WebExtension将事件监听器添加到所有嵌入式YouTube视频中

我正在尝试通过JSX反应中的嵌入式CSS添加背景图像,但它没有更新

将工具栏按钮添加到嵌入式查看器

Yocto / Bitbake配方,用于将空目录添加到rootfs嵌入式Linux

如何将嵌入式链接添加到 html 5 视频

将嵌入式媒体播放器组件添加到 JPanel 时出错

将CSS背景图像设置为嵌入式SVG符号?

可以使用Angular 4中的插值将值添加到嵌入式样式中

在嵌入式CSS背景图像中回显php会删除网址中的“ /”

html和CSS-容器中的嵌入式图像(白色背景)

在React JS中使用嵌入式CSS设置背景图像URL

如何使用硒从嵌入式CSS获取背景图像

使用MVC动态将CSS背景图像添加到Bootstrap 4巨型机

将背景图像添加到View Controller中

使用字节数组将文本添加到位图(已知为视频添加嵌入式字幕)

使用JLabel将背景图像添加到JFrame

使用reportlab将背景图像添加到EPS

使用 Seaborn & Matplotlib 将图像添加到绘图背景

将图像背景添加到主页

如何通过使用JavaFX中的Scene Builder将背景图像添加到AnchorPane?