Issue arising from background-image and content property size

.section--7__photos {
  height: 50vw;
  max-height: 70rem;
  margin: 0 8%;
  background: url("https://ableton-production.imgix.net/about/photo-8.jpg?crop=right&dpr=1.5&fit=crop&h=250&ixjsv=1.1.3&q=66&w=417") no-repeat top 0% center/ contain;
}
.section--7__text {
  margin: 0 8%;
  padding: 8%;
  background-color: #11c01f;
}
.section--7__text p {
  margin: 0;
}
<div class="section--7__container">
          <div class="section--7__photos"></div>
          <div class="section--7__text">
            <p class="text--main__1">
              Lorem...
            </p>        
          </div>

Trying to adjust the background image in a container that changes size based on viewport width. However, there is a gap between the container holding the image and its adjacent sibling (green text field). https://i.sstatic.net/6xLgS.png

<div class="section--7__container">
          <div class="section--7__photos"></div>
          <div class="section--7__text">
            <p class="text--main__1">
              Lorem...
            </p>        
          </div>

CSS

.section--7__photos {
  height: 50vw;
  max-height: 70rem;
  margin: 0 8%;
  background: url("Images/photo-8.jpg") no-repeat top 0% center/ contain;
}
.section--7__text {
  margin: 0 8%;
  padding: 8%;
  background-color: #11c01f;
}
.section--7__text p {
  margin: 0;
}

Answer №1

display:flex; justify-content:center;

If you want to overlay text on an image, use CSS properties.

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

What is the best way to adjust a fixed-width table to completely fill the width of a smartphone browser?

In an ancient web application, the design was primarily constructed using rigid tables: <div class="main"> <table width="520" border="0" cellspacing="0" cellpadding="0"> <tr> <td>...</td> </ ...

Placing divs of varying heights in a circular formation with a specific radius

Recently, I've been attempting to generate a multitude of divs (referred to as bars) and position them in a way that forms a circle in the center. To clarify, here's an example where all bars share the same width and height. Check out the JSFi ...

Does Google's caching process differ when using <span> tags instead of <h> tags for headings?

Does the choice between using <span class="heading"> and <h> tags impact search engine optimization for Google? As I'm constructing a website, I decided to style the headings and subheadings with <span>. However, I began to wonder i ...

The loading of Bootstrap was halted by WAMP

Hi there, I'm encountering some issues with my WAMP setup. Previously, my pages were loading fine on WAMP, but a few months back, I attempted to use a keyboard shortcut to refresh a tab on Chrome. After that, my Bootstrap stopped loading. Everything w ...

Enhancing the structure and authentication of license plates

I'm having trouble figuring out how to apply Javascript to the text area. Can you advise on whether it's best to use onfocus, onblur, or onclick? Here is the code for the text area: <input type="text" name="c_Kenteken" id="invoerKenteken" cl ...

Working with jQuery, CSS, and functions to modify the current tag's class

Let's keep it brief and straightforward: Here is my HTML <div id="headerVideoControls" class="overlayElement"> <div id="videoMuteUnmute" onclick="muteUnmuteVideo('headerVideo')">mute button</div> </div> Edited ...

A guide to implementing toggle functionality on child elements

After clicking the button, the entire sidebar toggles, but I only want the side menus to toggle. Here is the relevant HTML code: <nav id="sidebar"> <div class="sidebar-header"> <img src="/fintantra/image ...

Is it possible to alter preact-material-components to switch to mdc-theme--dark mode, thereby changing the CSS style of all descendant components?

I recently created a preact-cli app and added the following code in Header.js: document.body.classList.add('mdc-theme--dark'); However, when a user tries to switch from the light theme to the dark theme, only the background of the app changes. ...

Troubleshooting problems with scrolling on JavaScript in Edge, Opera, and Chrome

Currently, I am developing a fun CSGO-inspired box opening feature on my food recipe website that randomly selects recipes for users. However, I have encountered some challenges with the scrolling functionality. It seems to be incompatible with certain bro ...

Formatting list items in HTML

I have just finished coding the following HTML code: My main goal is to align the list items - HOME | All About Kittens | Feeding Your Kitten in a proper layout. Currently, they are displayed as a simple list. However, I would like them to be aligned ...

Tips for resolving the Firefox display problem with input[type="file"] using CSS

After researching articles, it became clear to me that input[type="file"] displays differently across various web browsers. I am in need of a simple solution using only CSS to address this issue as I only require adjusting the width of the element. The w ...

Tips for styling an array of objects using mapping techniques

I have an array of messages and I am currently using the map() function. Each message in the array has two keys - one for the author and another for the message content. What I want to achieve is to change the styles of the div tag when displaying the last ...

What is the best way to determine the size of the URLs for images stored in an array using JavaScript?

I am working on a project where I need to surround an image with a specific sized 'div' based on the image's dimensions. The images that will be used are stored in an array and I need to extract the height and width of each image before disp ...

Positioning JQuery tooltips

I've been developing a simple tooltip tool (check out the fiddle link below), but I'm encountering some issues with positioning. My goal is to have the tooltip appear centered and above the clicked link, however right now it appears at the top le ...

Troubleshooting Spring's difficulty in locating resource files (css, jsp...)

Currently, I am integrating a jsp file as a model from a Controller and aiming to incorporate CSS styles and JS libraries into the project structure. Project Structure Webcontent assets WEB-INF jsp For the configuration in web.xml: <web-app versio ...

Is there a way to dynamically change the title of a tab when new content is added to a minimized page?

Is anyone familiar with how websites like Facebook and Buzzfeed update their tab titles when there are multiple tabs open? I have noticed that sometimes they add a "(1)" or "(2)" to indicate changes on the page. Do they use JavaScript to achieve this eff ...

Preserve the height of the previous div following an AJAX request

I am currently facing an issue where I have a script that utilizes ajax to receive a response containing a cart string (html code) with items from the cart. Inside the response handler, there is another script that sets the height of each div in the cart s ...

Skrollr immediate pop-up notification

Can anyone help me figure out how to make text appear suddenly and then disappear using skrollr? I've been able to get it to fade in and out, but I want it to just show up without any transition. Here's the code I have so far: <div id="style" ...

Rows intersecting and stacking above one another

I designed a layout with some text and icons displayed in rows. While it appears properly on iOS, the rows overlap on Android. const criteriaList = [ { id: 0, title: 'Noor', checked: false }, { id: 1, title: 'Friends & Grades', ...

Step-by-step guide on creating a linear graph in CSS using a table

I am a newcomer to the world of CSS and I am looking to create a graph using CSS without the use of any libraries or frameworks. Can someone kindly assist me in drawing a linear graph using this HTML table? Appreciate any help in advance. <html> & ...