Adding background image to div using CSS

后端 未结 8 1709
终归单人心
终归单人心 2020-12-24 02:09

I have been trying to add background image to a div class using CSS, but I didn\'t have any success.

HTML code:

相关标签:
8条回答
  • 2020-12-24 02:32

    You can try this also for setting the class in a div section:

    /** CSS **/
    .content {
        background: url('http://www.gransebryan.com/wp-content/uploads/2016/03/bryan-ganzon-granse-who.png') center no-repeat;
    }
    
    .displaybg {
       text-align: center;
       color: #FFF;
    }
    <div class="content">
    
        <p class="displaybg">This is just a test</p>
    
    </div>

    0 讨论(0)
  • 2020-12-24 02:33

    Use:

    .content {
        background: url('http://www.gransebryan.com/wp-content/uploads/2016/03/bryan-ganzon-granse-who.png') center no-repeat;
     }
    
    .displaybg {
       text-align: center;
       color: #FFF;
    }
    
    0 讨论(0)
提交回复
热议问题