简体   繁体   English

使背景图像透明而不影响Jekyll主题中的前景文本

[英]Make background image transparent without affecting foreground text in Jekyll theme

I am a newbie with HTML and CSS. 我是HTML和CSS的新手。 I am using this Jekyll boostrap landing theme to build a static responsive website. 我正在使用这个Jekyll boostrap登陆主题来构建静态响应式网站。 I want to change the background image for it and make it transparent in order to highlight the foreground text. 我想为其更改背景图像并使其透明以突出显示前景文本。 I understand that there are similar questions asked already but they don't work when I tried to apply them for my code base. 我知道已经问过类似的 问题,但是当我尝试将其应用于我的代码库时它们不起作用。 I would appreciate if I could get a working solution for the css styling that the theme has. 如果能为该主题的CSS样式找到一个可行的解决方案,我将不胜感激。

The relevant html & css code that comes with the theme is as below 主题随附的相关html&css代码如下

<div class="intro-header">        
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="intro-message">
                    <h1>{{ page.title }}</h1>
                    <br><h3>{{ page.subTitle }}</h3>
                </div>
            </div>
        </div>

    </div>
    <!-- /.container -->

</div>

The CSS code is CSS代码是

.intro-header {
    padding-top: 50px; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */
    padding-bottom: 50px;
    text-align: center;
    color: #f8f8f8;
    background-size: cover;
}

@media (min-width: 200px) {
  .intro-header {
    background-image: url(/img/website_background_d5moc7_c_scale,w_200.jpg);
  }
}

/* more media queries for different widths */

@media (min-width: 1329px) {
  .intro-header {
    background-image: url(/img/website_background_d5moc7_c_scale,w_1329.jpg);
  }
}

@media (min-width: 1400px) {
  .intro-header {
    background-image: url(/img/website_background_d5moc7_c_scale,w_1400.jpg);
  }
}

.intro-message {
    position: relative;
    padding-top: 20%;
    padding-bottom: 20%;
}

.intro-message > h1 {
    text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
    font-size: 5em;
}

.intro-divider {
    width: 400px;
    border-top: 1px solid #f8f8f8;
    border-bottom: 1px solid rgba(0,0,0,0.2);
}

.intro-message > h3 {
    text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
}

@media(max-width:767px) {
    .intro-message {
        padding-bottom: 15%;
    }

    .intro-message > h1 {
        font-size: 3em;
    }

    .intro-divider {
        width: 100%;
    }
}

How do I modify the above code to make the background transparent and foreground bright? 如何修改上面的代码以使背景透明和前景明亮?

Thanks! 谢谢!

Set the Background Image to 'none' in CSS. 在CSS中将背景图片设置为“无”。 In order to override the theme styles, make it more specific. 为了覆盖主题样式,请使其更具体。 Don't directly edit the theme CSS file, It's a bad practice. 不要直接编辑主题CSS文件,这是一个不好的做法。 You have to write the below CSS in your CSS file. 您必须在CSS文件中编写以下CSS。

div.intro-header {
  background-image: none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM