What is the best way to shift a block to the left when the screen size is changed

My div block has text overlapping the image, and when I resize the screen, the block with the text gets smaller but stays in the same position. I want to move the block to the left side while resizing the screen so that the entire block fits on the screen.

How can I achieve this properly? Here is my current code:

.our-project-section {
  margin-top: 100px;
}

.zundas-project img {
  max-width: 100%;
  max-height: 50%;
  height: auto;
  width: auto;
}

.projects-wrapper {
  margin-top: 50px;
  padding-bottom: 60px;
}

.project-description {
  padding: 25px;
  width: 50%;
  height: auto;
  background-color: rgba(0, 0, 0, .5);
  position: absolute;
  top: 50%;
  right: -30%;
  color: #fff;
  text-align: center;
}

.project-description p {
  letter-spacing: 1px;
  margin-top: 20px;
}

.project-description h3 {
  position: relative;
}

.project-description h3::after {
  content: '';
  position: absolute;
  width: 80px;
  height: 3px;
  background: #fff;
  top: 32px;
  left: -85px;
  right: 0;
  margin: auto;
}

.project-description a {
  position: relative;
  top: 20px;
}
<section class="our-project-section">

  <div class="row">

    <div class="col-xs-12 col-md-8">

      <div class="projects-wrapper">

        <div class="zundas-project">

          <img src="https://static.dezeen.com/uploads/2018/02/riverfront-square-michael-green-lotus-newark-new-jersey-usa-largest-timber-office-building_dezeen_2364_col_1-852x537.jpg" alt="">
          <div class="project-description">
            <h3>Project Name</h3>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga id molestias enim molestiae, corporis at ad ipsum perferendis commodi dicta dolorem ea eos magnam reprehenderit quae temporibus. Animi quasi labore fugit reiciendis odit officiis
              reprehenderit saepe earum.</p>
            <a href="#">More Information</a>
          </div>

        </div>

      </div>

    </div>

  </div>

</section>

JSFIDDLE

Answer №1

Utilize media-query

@media screen and (max-width: 758px) {
  .project-description {
       right: 0;
    left: -19px;
  }
}

Check out the example on fiddle:https://jsfiddle.net/kp6L28rz/11/

.our-project-section {
    margin-top: 100px;
}

.zundas-project img {
    max-width: 100%;
    max-height: 50%;
    height: auto;
    width: auto;

}

.projects-wrapper {
    margin-top: 50px;
    padding-bottom: 60px;
}

.project-description {
    padding: 25px;
    width: 50%;
    /* width: 400px; */
    height: auto;
    background-color:rgba(0,0,0,.5);
    position: absolute;
    top: 50%;
    /* right: -80px; */
    right: -30%;
    color: #fff;
    text-align: center;

}

.project-description p {
    letter-spacing: 1px;
    margin-top: 20px;
}

.project-description h3 {
    position: relative;
}

.project-description h3::after {
    content:'';
    position:absolute;
    width:80px;
    height:3px;
    background:#fff;
    top:32px;
    left:-85px;
    right:0;
    margin:auto;
}

.project-description a {
    color: #fff;
    font-weight: 800;
    position: relative;
    top:20px;
}
@media screen and (max-width: 758px) {
  .project-description {
       right: 0;
    left: -19px;
  }
}
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

        <div class="container">
            <section class="our-project-section">

                <div class="row">

                    <div class="col-xs-12 col-md-8">

                        <div class="projects-wrapper">

                            <div class="zundas-project">

                                <img src="https://static.dezeen.com/uploads/2018/02/riverfront-square-michael-green-lotus-newark-new-jersey-usa-largest-timber-office-building_dezeen_2364_col_1-852x537.jpg" alt="">
                                <div class="project-description">
                                    <h3>Project Name</h3>
                                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga id molestias enim molestiae, corporis at ad ipsum perferendis commodi dicta dolorem ea eos magnam reprehenderit quae temporibus. Animi quasi labore fugit reiciendis odit officiis reprehenderit saepe earum.</p>
                                    <a href="#">More Information</a>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

        </div>

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

Exploring the Spacing Between ng-repeat Items in Angular

Encountering an issue with multiple ng-repeat elements displaying div elements as inline-block. A strange gap appears between the elements when transitioning from one ng-repeat to the next, which is visible in the provided image: A demonstration of this p ...

Attempting to change the appearance of my jQuery arrow image when toggling the visibility of content

Here is a sample of my JQuery code: $(document).ready(function() { $(".neverseen img").click(function() { $(".neverseen p").slideToggle("slow"); return false; }); }); Below is the corresponding HTML: <div class="neverseen"> <h1> ...

Align text within HTML with the use of Bootstrap

Example data value category type item1 100 food fruit item2 50 drinks soda item3 75 snacks chips I want to achieve this forma ...

Having trouble resolving row border issues with CSS in DataTables?

I need to enhance the appearance of specific rows in my table by adding a darker border at the bottom. To achieve this, I have assigned a custom class (des-rec-row) to the rows and included the following CSS code: .des-rec-row { border-bottom: 1px soli ...

Implementing a line break within a JavaScript function specifically designed for formatting images

As I am not a javascript developer, the code I have been given for debugging is somewhat challenging. The issue at hand involves an iOS module where a .js CSS file has been set up and images are loading improperly, resulting in the need for horizontal scro ...

JQuery $ incompatible with the Sufee framework

After downloading the Sufee template from the Sufee GitHub page which includes an import of jquery: <script src="vendors/jquery/dist/jquery.min.js"></script> Following that line, I proceeded to define my own JavaScript using the if-else sta ...

Achieve the sticky effect for text in a HTML div using CSS to keep it anchored to the

Seeking advice on how to create a floating box that remains in the bottom right corner of a div using CSS. Any tips or suggestions are appreciated! (Here's an example of what I'm aiming for: https://i.stack.imgur.com/DkD5C.png) ...

Using JavaScript to make an AJAX request when a dropdown menu from

Looking to update a graph created with Google Chart API using a drop-down menu. Currently facing a few issues. The dropdown is sending a request to the wrong URL. Instead of /graph/, it's sending data to the current page, which is /services/. This ...

Applying the margin auto property and setting display to inline block within a while loop

I am utilizing a while loop to showcase various groups of people in different tables. I have discovered that when I use inline-block, the margin auto function does not work. I would like these two tables to be displayed inline and centered in the b ...

Creating colorful containers using Bootstrap

Hey there, I am interested in creating small colored boxes to represent different meanings for each color. I came across this code snippet but I am unsure how to adjust the size: <div class="p-3 mb-2 bg-primary text-white">.bg-primary</d ...

Spacing between a pair of jQuery datepicker panels

https://i.sstatic.net/Xnbh1.png Is there any way to add spacing between two tables inside the jquery date picker with a common header? I've tried various solutions like adding padding to the parent div, but haven't been able to fix it. Can anyon ...

Is there a way to randomly change the colors of divs for a variable amount of time?

I have a unique idea for creating a dynamic four-square box that changes colors at random every time a button is clicked. The twist is, I want the colors to cycle randomly for up to 5 seconds before 3 out of 4 squares turn black and one square stops on a r ...

Launching an image link within the same location on the subsequent page to which it is directed

I'm completely new to creating websites so I may not be using the correct terminology. I've searched with various terms and ideas but haven't found any solutions to help me ask my question effectively or find examples of what I'm lookin ...

The browser is lagging behind a few frames when repainting on high-resolution displays

Currently, I'm working on a website that features an infinite grid. Users have the ability to navigate through the grid by simply holding down the right click on their mouse and moving it around. The technical details: To achieve this functionality, ...

Tips on expanding the background beyond the boundaries of a parent container with a specific width limit

Could you please take a look at the code snippet below? I am dealing with a situation where I have a container with a fixed width, and inside that container, there are rows whose width exceeds that of the parent container. Some of these rows have a backgro ...

Tips on adjusting the CSS to fix the scrolling issue caused by images in a carousel slider

I am facing an issue where a scroll is being created and it appears offset on different screen sizes: https://i.sstatic.net/KYTCN.jpg I need help to resolve this problem and make it responsive. Even after trying to add overflow: hidden; it still doesn&a ...

Drop-down Navigation in HTML and CSS is a popular way to create

My navigation menu is functioning well and has an appealing design. The HTML structure for the menu is as follows: <div id="menubar"> <div id="welcome"> <h1><a href="#">Cedars Hair <span>Academy</span></ ...

The panel's placement shifts when the browser window is expanded

Currently, the issue I am encountering involves an ASP.NET website with a header, sidebar, and additional right sidebar. When I resize the browser window, the left sidebar overlaps the content page, resulting in mixed-up controls. Please refer to the image ...

Learning how to nest <div> elements within another <div> and then utilize positioning in HTML/CSS for beginners

Struggling to create a simple 4 block layout in the center of the page. Currently, I am using the following CSS on the parent div (class=wrapper) .wrapper { margin:0 auto; width:960px; } However, this centers all child divs but I am unable to position th ...

Tips for repairing buttons in the CSS container

The buttons in the CSS search-box are not staying fixed as intended. They should be within the search box, but instead, they are protruding out of the panel. I attempted to utilize z-index, but it did not produce the desired outcome. https://i.sstatic.n ...