in Education by
I want to have a .png image to be 1) exactly in the centre of a div, no matter the device size and 2) to be above another .png image in the same div. Here is my html:
image image
And here is my CSS: #phone { position: absolute; left: 67%; top: 45%; z-index: 10; opacity: 100%; width: 200px; } The redphone.png is the image I'm referring to in my specifications above. Using position: absolute; and z-index: 10; seems like the only way I get the .png to be above the other image, but it seems to place it outside the div. Whereas using, say, position: relative; with the same z-index displaces the png above the other image but keeps it contained in the same div. This is the web page, if anyone wants to view the page source and see all the code. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can try adjusting the left and top to 50%, but also add transform: translate(-50%, -50%);. Result: #phone { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 200px; }
image image
Run code snippetExpand snippet

Related questions

0 votes
    I have a div and an iframe on the page the div has z-index: 0; the iframe has its content with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I have a div and an iframe on the page the div has z-index: 0; the iframe has its content with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I have a div and an iframe on the page the div has z-index: 0; the iframe has its content with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I have a div and an iframe on the page the div has z-index: 0; the iframe has its content with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I have a div and an iframe on the page the div has z-index: 0; the iframe has its content with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I'm a visual/UI designer working on a project/product which has been designed by another designer. This ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm trying to overlay 2 ImageViews, one with the background and one with an animated (using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I'm trying to overlay 2 ImageViews, one with the background and one with an animated (using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    which of these is not an image file format PNG GIF BMP DOCX Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    [reposting deleted question with more detail] I've searched for an answer to this but not found a reference ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    [reposting deleted question with more detail] I've searched for an answer to this but not found a reference ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    [reposting deleted question with more detail] I've searched for an answer to this but not found a reference ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    The IBM _________ analytics appliances combine high-capacity storage for Big Data with a massively-parallel processing ... Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    high level language are translated into machine language with the help of_ or _ Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    high level language are translated into machine language with the help of Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
...