pycharm HTML背景

afdcj2ne  于 2023-10-20  发布在  PyCharm
关注(0)|答案(2)|浏览(92)

伙计们,我是新来的
所以我目前正在尝试使用pycharm制作一个html网站,我现在做了大部分,但我想添加一个背景图片或颜色。有人知道密码吗?
我试

<img src='background.jpeg'>

<style> </style>

我把照片保存在电脑上,但它不起作用

qni6mghb

qni6mghb1#

你是说下面的东西吗

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="style2.css"> <!-- include the path to the style2.css if it's not in the same folder-->
    <title>Document</title>
</head>
<body>
    <h1>Something...</h1>
</body>
</html>

在你的style2.css中

body{
    background-image: url('images/somepicture.jpeg'); /*assuming you have saved the picture in the images folder */
    background-size: cover;
}
2sbarzqh

2sbarzqh2#

你的照片也在index.html里吗?或者你用Internal-Styles来做

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;
      background-image: url('images/somepicture.png');} /* Path to your picture */
h1   {color: blue;}
p    {color: red;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

相关问题