The attempt to showcase items in a div element using inline display did not produce

I am having trouble with creating a webpage. I have designed a website but I am struggling to get it right. I have included my HTML and CSS code below.

What I am trying to achieve is a header at the top, followed by several sections containing a photo on the left and a paragraph on the right, alternating between the two layouts. However, I am facing issues with the first block of information. In my CSS, I have defined the structure of my content, including headers and div elements for photos and paragraphs, but I can't seem to display them inline-block. Where am I going wrong? I have also posted an image of my current progress.

   .container {
  margin: auto;
}

.row {
  display: flex;
  flex-wrap: wrap;
}
 <section class="why-we-help">
    <div class="container">
        <div class="row">
            <div class="home">
                <div class="info">
                    <h1>Dlaczego chcemy pomóc?</h1>
                </div>
                <div class="content">
                    <img class="img" src="images/2.jpg" alt="najwazniejsza jest miłość">
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quisquam id deserunt,
                        enim
                        temporibus autem itaque exercitationem, maiores facere magni minima iure rem facilis
                        adipisci
                        porro debitis, quam ad obcaecati.</p>
                </div>
            </div>
        </div>
    </div>
</section>

.home {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  background: #000000;
}

.info {
  margin: 35px auto;
}

.info h1 {
  color: #ffffff;
  font-size: 2em;
  font-weight: 600;
}

.content {
  display: flex;
 display: inline;
}

.content img {
  flex: 0 0 50%;
  width: 50%;
}

.content p {
  flex: 0 0 50%;
  width: 50%;
}

https://i.stack.imgur.com/6tBRl.jpg

Answer №1

Experiment with the properties display:flex, flex-direction: row, and flex-direction: row-reverse

Answer №2

When we talk about inline, it generally means being positioned side by side horizontally. To achieve this effect, you can simply remove the display:inline; property from your .content class as shown below:

.content{
  display:flex;
  /*Additional flex box properties*/
  flex-direction:row;
  flex-wrap:wrap;
 }

Answer №3

Here is a solution that may meet your needs.

To improve the structure and organization of the code within the section, I made some adjustments to manage the css properties of each element, making it easier to understand.

I've also included a fixed header at the top for added functionality.

.header {
  position: fixed;
  top: 0;
  z-index: 1000 !important;
  
  width: 100%;
  height: 2rem;
  padding-top: 0.5rem;
  
  background-color: white;
  text-align: center;
}

.why-we-help {
  position: absolute;
  top: 1.5rem;
  
  height: 1000px;
  margin: auto;
  padding-top: 0.5rem;
  
  background-color: black;
  color: white;
}

.title {
  text-align: center;
}

.container {
  display: flex;
  flex-direction: column;
  
  text-align: justify;
}

.row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.row:nth-of-type(2n) {
  flex-direction: row-reverse;
  margin-right: 1rem;
}

.img {
  width: 100%;
}

.row:nth-of-type(2n) .img {
  margin-left: 1rem;
}
<div class="header">This is a header that will always stay on top</div>
<section class="why-we-help">
  <h1 class="title">This is the title of the section</h1>
  <div class="container">
    <div class="row">
      <img class="img" src="images/2.jpg" alt="Image 1">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quisquam id deserunt, enim temporibus autem itaque exercitationem, maiores facere magni minima iure rem facilis adipisci porro debitis, quam ad obcaecati.</p>
    </div>
    <div class="row">
      <img class="img" src="images/2.jpg" alt="Image 2">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quisquam id deserunt, enim temporibus autem itaque exercitationem, maiores facere magni minima iure rem facilis adipisci porro debitis, quam ad obcaecati.</p>
    </div>
    <div class="row">
      <img class="img" src="images/2.jpg" alt="Image 1">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quisquam id deserunt, enim temporibus autem itaque exercitationem, maiores facere magni minima iure rem facilis adipisci porro debitis, quam ad obcaecati.</p>
    </div>
    <div class="row">
      <img class="img" src="images/2.jpg" alt="Image 2">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quisquam id deserunt, enim temporibus autem itaque exercitationem, maiores facere magni minima iure rem facilis adipisci porro debitis, quam ad obcaecati.</p>
    </div>
  </div>
</section>

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

CSS not reflecting changes after the href of the <link> tag has been updated

Hey there, I'm a beginner in the world of programming and currently facing an issue that I need help with. My goal is to dynamically update the CSS of my webpage by using JQuery to change the 'href' value in the link tag. In order to test t ...

What is the procedure for modifying the height of a button in HTML?

I wanted to add a flashing "Contact Us" button to the menu bar of my website to immediately attract people's attention when they visit. Here is the javascript code I used: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&g ...

issue with jquery fade toggle not working properly on Bootstrap website

My website is built using Bootstrap and jQuery. I am facing an issue where the fadeToggle() function on a div element is not displaying properly - it remains hidden all the time. Can anyone provide insight into what might be causing this problem, or sugg ...

How can I update the color of table rows after the ng-repeat has been implemented?

My current project involves Django, Python, and a bit of AngularJS. I have a dynamic history table that grows as data is added. I am looking to apply some simple CSS to this table - specifically, I want to give every even-numbered row a black background ...

When scrolling, the text or logo inside the navbar seems to dance with a slight wiggling or

I recently implemented a code to create a logo animation inside my navigation bar that expands and contracts as I scroll, inspired by the functionality of the Wall Street Journal website. However, this implementation has caused some unintended side effects ...

Does using the HTML doctype result in adding extra whitespace?

Could someone provide an explanation as to why setting a doctype of <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> and <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> results in different rendering of the following ...

Can the functions passed into Material-UI withStyles() be relocated within the component?

Attempting to break down the components of my dashboard into smaller parts has proven challenging due to their dependence on drawerWidth. Initially, I considered moving drawerWidth into the state so it can be passed down to each component. However, I encou ...

Steps to activate a single button within a deactivated fieldset

Is there a way to deactivate all elements within a Fieldset, while keeping certain buttons active? Check out this demo. <fieldset ng-disabled="true"> <legend>Personalia:</legend> Name: <input type="text"><br> Em ...

The hyperlink within the dropdown menu in HTML code is malfunctioning

I'm currently working on my personal website using HTML and CSS with textedit. I've successfully created functional links for the main navigation menu headings, but I'm encountering issues with the dropdown options. Whenever I try to click o ...

Setting up JW Player with a YouTube Embed URL

Embed link Is it possible to embed a YouTube link in my JW Player without disrupting the design? I have a specific design for the JW Player frame that I need to retain while incorporating the YouTube link. I have searched extensively but haven't foun ...

Tips on avoiding the accumulation of event handlers when dealing with click events triggered by the document selector in jQuery

I am currently working on a project that involves using AJAX to load various pieces of HTML code. This is done in order to properly position dynamic buttons within each portion of the HTML content. In my case, I need to trigger click events on the document ...

Why do certain full screen websites not align with my screen width properly?

When I use my 1920px wide screen and inspect the HTML tag with Chrome DevTools on websites like Firebase or Facebook Messenger, I notice a difference: Despite my screen width being 1920px, these websites appear fullscreen with an HTML tag width of 1440px. ...

Site optimized for mobile devices

I need to create a website that is optimized for mobile devices like Android, iPhone, and Blackberry, as well as desktop and tablet. The screen resolutions of these devices can vary greatly. My supervisor has suggested developing one site that can adjust ...

Transforming the style of a particular element within React using Array().fill().map's method

Looking for a way to dynamically change the color of an array in React + styled jsx? Let's say you want to change the color when the number of elements in the array is a multiple of 4 (e.g. the index is 4, 8, etc.) Is there a clever solution to achi ...

Arranging elements and buttons inside of components to create a cohesive design

My React application consists of two components: Open and Save. The Save component has a button labeled as saveButton. On the other hand, the Open component contains an openButton, as well as a stopButton and executeButton that are conditionally displayed ...

Utilizing two distinct CSS frameworks within a single Rails application

At the moment, I have an application with its frontend built using Bootstrap 3 (leveraging the bootstrap-rails gem). Now, I am looking to incorporate the Materialize.css framework into the same app. After downloading the Materialize.css stylesheet, my conc ...

Placing numbers at the top of the HTML table cell for better visibility

I am currently utilizing a two-column HTML table to showcase a list of rules. In one column, I have the rule's number, while in the other, I have the rule itself. However, I've noticed that the rule numbers are appearing near the bottom of their ...

Mysterious attributes of angular 6's <table mat-table> tag

This particular question regarding the angular material table has not been duplicated in any other discussions. Other similar questions pertain to angular versions 2-5, not version 6 The issue I am encountering is as follows: Can't bind to 'dat ...

Banner Placement

Is there a way to arrange 3 banners without using absolute positioning? I prefer to use relative positioning so that the footer doesn't overlap with the page. How can I achieve this layout? .bms { height: 810px; left: 0; position: absolute; ...

Center align the mat-expansion-panel material component in a vertical orientation

When working with the mat-expansion-panel component alongside a mat-accordion, I've encountered an issue where the items are not aligning vertically at the center/middle. I'm unsure of the proper method to achieve vertical alignment for the conte ...