有没有一种方法可以使图像背景变暗,使文本显示得更好?

时间:2020-06-21 18:20:53

标签: css background

第一个问题,希望我能正确回答。

我正在制作主页,并且背景是图像。我正在尝试将其变暗,以使我的文字显示得更好。我相信这就是所谓的叠加图像。我已经查找了如何执行此操作,但是我无法将其代码转换为我的代码。这是我的CSS:

body {
    background: url(https://worldstrides.com/wp-content/uploads/2017/10/Columbia.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-color: rgba(0,0,0,0.2);

2 个答案:

答案 0 :(得分:0)

您拥有文字本身

.text{
    color:(any dark color can go in here) 


}

<p class = text>text<p>

答案 1 :(得分:0)

您可以将from youtube_search import YoutubeSearch results = YoutubeSearch('Sabaton', max_results=10).to_dict() if len(results) > 0: dictionary = results[0] print(f"youtube.com{dictionary.get('link')}") else: print("No results found.") 应用于背景。这样会在背景图片上方创建一个图层,该图层可以是您想要的任何颜色。

linear-gradient

上面的代码将在图像上方创建一个蓝色透明层。

Jsfiddle (example)