首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用.png镜像作为div背景?

如何使用.png镜像作为div背景?
EN

Stack Overflow用户
提问于 2021-05-31 02:17:00
回答 1查看 40关注 0票数 0

看看我目前的网页,是用下面的tailwindcss页面开发的:

现在我想要实现的是有一个.PNG背景,而不是在中间的空白绿色背景。

我是Tailwind的新手,所以我习惯于在css文件中为特定的background: url(..)类设置一个div。查看TailwindCSS文档here about backround-image,我看不到类似的功能。

下面是我为该特定div编写的代码片段:

代码语言:javascript
复制
<!--        Content: background image url should be in this div, right?-->
    <div class="flex-1 pt-2 text-2xl font-bold mt-2 mb-2 bg-green-50 rounded-br-3xl">
        <div>
<!--Search field -->
            <div class="w-full">
                <form class="rounded">
                    <div class="px-5">
                        <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="username" type="text" placeholder="Ask me anything (Press CTRL+K to focus)")>
                    </div>
                </form>
            </div>
            <!-- content -->   
            <div class="px-5 pt-8">Course content here</div>
        </div>
    </div>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-31 02:26:06

您可以通过编辑tailwind.config.js文件的theme.backgroundImage部分来添加自己的背景图像:

// tailwind.config.js

代码语言:javascript
复制
  module.exports = {
    theme: {
      extend: {
        backgroundImage: theme => ({

         'hero-pattern': "url('/img/hero-pattern.svg')",

         'footer-texture': "url('/img/footer-texture.png')",
        })
      }
    }
  }

因此,例如,hero-pattern将变为bg-hero-pattern。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67764463

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档