我有这个简单的 html 页面
<html>
<head>
<meta charset="UTF-8">
<title>AlgoStash</title>
<style>
html {
background: url("<?php echo base_url('assets/sea.jpg');?>" no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<audio src="<?php echo base_url('assets/avinu.mp3');?>" autoplay></audio>
</body>
<!-- אבא שלנו, המלך שלנו -->
</html>
生成此 html
<html>
<head>
<meta charset="UTF-8">
<title>AlgoStash</title>
<style>
html {
background: url("http://algopesa.com/assets/sea.jpg" no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<audio src="http://algopesa.com/assets/avinu.mp3" autoplay></audio>
</body>
<!-- אבא שלנו, המלך שלנו -->
</html>
但是,页面不显示图像。
为什么这段代码
html {
background: url("http://algopesa.com/assets/sea.jpg" no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
虽然图像存在,但不产生背景图像?。我怎样才能使图像显示?。
最佳答案
您需要关闭url(...)
,否则将无法运行:
<html>
<head>
<meta charset="UTF-8">
<title>AlgoStash</title>
<style>
html {
background: url("<?php echo base_url('assets/sea.jpg');?>") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<audio src="<?php echo base_url('assets/avinu.mp3');?>" autoplay></audio>
</body>
<!-- אבא שלנו, המלך שלנו -->
</html>
关于html - 使用远程 url 的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45756660/