Effect: <div class="imgs"> <!-- Background image --> <div class="background"> <img :src="item.voteTime ? imgSrc1:imgSrc2" width="100%" height="100%" alt="" /> </div> <!-- Text --> <div class="front"> <div v-if="item.voteTime"> <p>Thank you very much! </p> <p>You have voted: <span>{{item.voteTime}}</span></p> </div> <p v-else style="color:#999999">Sorry, you have not completed the voting~</p> </div> </div> data() { return { imgSrc1:require('@/common/imgs/yitoupiao.png'), imgSrc2:require('@/common/imgs/weiwancheng.png'), } }, The large div outside: set the width and height; .imgs { background: #fff; position: relative; width: 100%; height: 250px; color: #195541; .background{ // width:100%; // height:100%; /**The width and height are 100% so that the image fills the screen*/ // z-index:-1; z-index:1; position: absolute; width: 250px; height: 100%; right: 20px; bottom: 0px; } .front{ z-index:2; position: absolute; text-align: center; top: 39%; left: 25%; font-weight: normal; line-height: 40px; font-size: 28px; } } A bug was encountered during the development process: I initially set the z-index of the background image to -1, which resulted in the background image sometimes being displayed on the h5 and sometimes not. Later, I changed it to a positive number 1 to solve this problem. This is the end of this article about how to use CSS to put text on a background image. For more information about using CSS to put text on a background image, please search 123WORDPRESS.COM’s previous articles or continue browsing the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Use overflow: hidden to disable page scrollbars
>>: Docker container data volume named mount and anonymous mount issues
The method to solve the problem of forgetting the...
Communication between containers 1. Network shari...
What are the shutdown commands for Linux systems?...
Table of contents Solution Analysis slice Resume ...
1. In Windows system, many software installations...
HTML: Title Heading is defined by tags such as &l...
Table of contents 1. Handwritten instanceof 2. Im...
Table of contents Product Requirements Ideas Prob...
Preface When I was typing my own personal blog, I...
How to change the password in MySQL 5.7.18: 1. Fi...
Introduction to kubectl kubectl is a command line...
Preface Today I encountered a very strange proble...
Operating system win10 MySQL is the 64-bit zip de...
This article shares the specific code for WeChat ...
1. Confirm whether MySQL has been installed. You ...