Placing text beneath a dynamically resized image

Currently having some CSS problems as I resize images based on the user's browser window size. Unfortunately, this causes my text to overlap with the image. One solution is setting a fixed height in pixels for the container, but it looks off when resizing the browser.

You can take a look at a simplified version of the issue here

<div id="coverContainer" style="position:relative; height:auto; width:100%;" class="center-block">
    <img class="photo center-block" src="https://www.google.co.uk/images/srpr/logo11w.png" />

</div>


<div class="center-block">
    <h2 style=" color:black;">
        Welcome to my website
    </h2>
    <div id="news">
        <h2 style="color:black;">News</h2>
        <p style="color:black;">Example Text Example Text Example Text Example Text Example Text Example Text Example Text Example Text Example Text .</p>
    </div>
</div>

css

.photo {
    box-shadow: 3px 3px 3px black;
    position:absolute;
    max-width: 100%; 
    height: auto;
}

I aim to always have the text positioned below the image.

Any assistance on this matter would be highly appreciated.

Thank you

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Does the height of a block element change based on the font size?

Does the font size of content affect the height of a block element? Let me demonstrate what I'm talking about, take a look at this example fiddle If you enlarge the font size of the class .p within the div, you'll notice that the div's hei ...

YouTube videos cannot be embedded using an iframe on Firefox

I inserted a YouTube iframe code inside a div element. <div id="box"> <iframe width="300" height="315" src="//www.youtube.com/embed/82fn4mcNGJY" frameborder="0" allowfullscreen></iframe> </div> After applying CSS to sc ...

"Select targets that have more than one class assigned to them, all within a

I am working on styling HTML elements with multiple classes and need to assign them different styles within one rule. For example, in my CSS: .border-blue { border: 1px solid blue; } .background { background: url(bg.gif); } And in my HTML: <d ...

Cutting Out Sections of a List

I'm currently working on an app that involves looking up and navigating to specific locations. I've encountered an issue with the coordinates in my code containing a ',0' at the end, which is not compatible with Google Maps. Manually re ...

What is the best way to create a line break in a flex div container to ensure that overflowing items wrap onto the next line using

Using material-ui popper to display a list of avatars. Trying to arrange the avatars horizontally within the popper. <Popper style={{ display: 'flex', maxWidth: '200px', }}> <div style={{ marginRight: '20px' }}&g ...

Ways to retrieve the count of child divs using css or sass

Imagine you have a CSS list structured like this: <ul class="parent"> <li class="child"></li> </ul> The child items are generated using an iterator. Is there a way to determine the number of children within the parent element us ...

JavaScript progress bar with extended duration, inspired by the success-oriented approach

Currently, I am in search of a unique solution or plugin that can replicate the same effect as Kickstarter's crowd fund long term progression bar. It seems like existing solutions only offer short term dynamic progress bars that indicate the percentag ...

CSS does not seem to support nesting list elements within other list elements

<ul> <li>One <li>two</li> </li> </ul> Attempted to target the second <li> with: li li { background: "red"; } Questioning the reason for it not functioning as expected. ...

The Border Radius Problem in Google Chrome

Greetings! I am currently working on a project for a website and have encountered an issue with the gallery on the projects page. The images are meant to be displayed as circles, and when hovered over, they should maintain their circular shape and have a b ...

Designing a Bootstrap layout with twin divs adjacent to each other

I am trying to design a webpage with two Divs positioned side by side using bootstrap styles. However, the code I have been using is not yielding the desired outcome. Is there anyone who can offer me some guidance on how to achieve this? Thank you. < ...

Looking for a way to include the current page's HTML code when exporting a CSV file

Here is the HTML code showcasing the Export button: <form method="post" name="download_csv" class="pull-right" enctype="multipart/form-data"> <button type="submit" name="Export" class="btn btn-success" >Export to excel</button> < ...

styling multiple elements using javascript

Recently, I created a jQuery library for managing spacing (margin and padding). Now, I am looking to convert this library to pure JavaScript with your assistance :) Below is the JavaScript code snippet: // Useful Variables let dataAttr = "[data-m], [d ...

Problem with the hover functionality of the <li> tag

I'm having an issue with applying the hover property to the li element in the sidebar. The hover effect works, but the icon tag is not showing the hover effect. I want the icon to also show the hover effect along with the li's hover effect. Here ...

Can one determine if a webpage is being displayed within an Infragistics igDialog?

Occasionally, my web page is displayed without a container and other times it's embedded within an igDialog of another container page, based on the user's navigation throughout our web application. Is there a way, using pure javascript or jQuery ...

Unable to view mobile version on HTML page / lack of responsiveness observed

<body> <nav class="navbar navbar transparent"> <div class="container-fluid logo"> <div class="navbar-header"> <a class="navbar-brand" href="#"> <img src="images/Logo.png" /> & ...

Dynamic content in CSS horizontal alignment

In a parent div with fixed width, I have dynamically created divs that I want to distribute horizontally without knowing the exact number of elements. I tried using the "Using inline-block and justified text" technique from a CSS Tricks page but it did not ...

Implementing a watermark image on every page in CodeIgniter: Step-by-step guide

Is there a way to add a watermark image to all PHP pages that remains fixed at the center? <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/wstyle.css"> This is what's in the wstyle.css file: body { ba ...

Footer disappearing on iPad Safari viewing

I'm currently facing an issue with the footer on a website I'm working on. Everything is working fine except for when the site is viewed on Safari on an iPad. The footer is appearing way above the bottom of the page and after spending an hour try ...

The iframe is not large enough to contain all the HTML content

I'm encountering a problem with a website I'm currently developing - specifically, I am struggling to embed an HTML document into an iframe in a manner that fills the entire page. Additionally, I am utilizing Angular to retrieve the HTML document ...

Ways to ensure next/image takes up all available grid space

Is there a way to make the next/image element span from grid 1 through 8? It seems to work fine with the imgtag but not with next/image. .project { display: grid; margin-bottom: 4rem; grid-template-columns: repeat(12, 1fr); align-items: center; } ...