Combine a frame with a photo side by side

When I put a frame and a picture together, my photo is not fully displayed. In each size (such as mobile phone, larger size, and medium size), only a part of the image is shown. Can anyone help me with this issue?

Here is my HTML markup:

<!-- about section -->
<section id="about" class="bg-secondary">
<div class="container-fluid">
<div class="row">
    <!-- about img column -->
    <div class="col-md-6  about-picture height-80 img-responsive "></div>
    <!-- about text column -->
    <div class="col-md-6 about-text height-80 px-5 d-flex align-items-center justify-content-center">
<!-- this is for centering -->  
<div class="about-text-center">
    <!-- title -->
    <div class="row">
    <div class="col text-center">
    <h1 class="display-4 text-uppercase text-dark mb-0"><strong>about</strong></h1>
    <div class="title-underline bg-warning"></div>
    <p class="mt-2 text-capitalize">hi it's just a test</p>
    </div>
</div>
<!-- end of title -->
<!-- single item -->
                            
</div>  
</div>      
</div>  
</div>
</section>  

This is my CSS:

body {
    font-family: 'Roboto', sans-serif;
}

.height {
    min-height: 100vh;
}

.title-underline {
    width: 200px;
    height: 5px;
    margin: 0 auto;
}

.height-80 {
    min-height: 100vh;
}

.height-11 {
    max-height: 11vh;
}

.about-picture {
    background: url("https://cdn.mos.cms.futurecdn.net/6t8Zh249QiFmVnkQdCCtHK.jpg");
}

Answer №1

To implement a background image properly, you must specify its size and position while ensuring it doesn't repeat. Otherwise, the browser will default to certain values.

Below is the CSS code to achieve this. Each value is explicitly set for clarity:

.about-picture {
background-image: url("https://cdn.mos.cms.futurecdn.net/6t8Zh249QiFmVnkQdCCtHK.jpg");
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}

You can adjust the positioning as needed, but using 'contain' ensures the entire image remains visible regardless of column dimensions on different devices.

Answer №2

Upon reviewing your code, I have determined that placing the image in the CSS may not be feasible in this case. I have made adjustments to the CSS section in .about-picture.

In addition, I have modified the HTML markup in this section:

<div class="col-md-6 about-picture">
  <img src="https://cdn.mos.cms.futurecdn.net/6t8Zh249QiFmVnkQdCCtHK.jpg">
</div>

Here is the edited version from my end:

<html>
<head>
  <meta charset="UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
  <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
    <style>
            body{
            font-family: 'Roboto', sans-serif;
            width: 100%;}

                .height{
            min-height: 100vh;}       

                .title-underline{

            width: 200px;
            height: 5px;
            margin: 0 auto;}


                .height-80{
            min-height: 100vh;}

                .height-11{
            max-height: 11vh;}

                    .about-picture{
                        align-items: center!important;
                    }
                .about-picture img{
                width: 100%;
                
                position: relative;
                padding-top: 120px;
                }
    </style>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c0e0303181f181e0d1c2c584259425f">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
  <title>Document</title>
</head>
<body>
     <!-- about section -->
     <section id="about" class="bg-secondary">
        <div class="container-fluid">
        <div class="row">
            <!-- about img column -->
            <div class="col-md-6 about-picture">
                <img src="https://cdn.mos.cms.futurecdn.net/6t8Zh249QiFmVnkQdCCtHK.jpg">
            </div>
            <!-- about text column -->
            <div class="col-md-6 about-text height-80 px-5 d-flex align-items-center justify-content-center">
        <!-- this is for centering -->
        <div class="about-text-center">
            <!-- title -->
            <div class="row">
            <div class="col text-center">
            <h1 class="display-4 text-uppercase text-dark mb-0"><strong>about</strong></h1>
            <div class="title-underline bg-warning"></div>
            <p class="mt-2 text-capitalize">hi  it is a test</p>
            </div>
        </div>
        <!-- end of title -->
        <!-- single item -->
                                    
        </div>  
            
        </div>      
            
        </div>  
        </div>
            </section>  
</body>
</html>

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

The left border consistently occupies any leftover space within the container

I have encountered an issue with my code where the border does not fill the empty space in the div container when there is only one item li present, but works fine if there are multiple items. The problem can be seen in the image below: https://i.sstatic. ...

Attempting to relocate various containers

My task involves handling a group of randomly placed boxes on a webpage, each painted in random colors. I am currently attempting to enable their movement from one location to another. Despite being a seemingly simple task, my lack of familiarity with mous ...

Demonstrate complete attendance by detailing specific days of presence and days of absence within a specified date range

In order to track the attendance of employees, I have a log that records when an employee is present or absent on specific dates within a given interval. Let's consider the following date range: $from = "2019-03-01"; $to = "2019-03-05"; Here is a ...

Modify the stroke attribute of the <path> element using CSS

I have a generated svg path code that I want to customize using CSS to remove the default stroke. How can I override the stroke property and set it to none? code: <div class="container" style="position: absolute; left: 3px; z-index: 1;"> <svg he ...

using a tag in flex can disrupt the arrangement of the box's design

What could be the reason for this issue? Is it possible to make the hyperlink appear inline with the rest of the text? .test { padding: 25px; display: flex; height: 100%; text-align: center; font-size: 25px; font-weight: 600; ...

Clicking the button in Bootstrap to trigger an event

What is the best way to implement a bootstrap button that triggers a modal when clicked? Should I use JavaScript for this functionality, and if so, where should it be placed in the code? Here is my current code snippet that does not seem to be working as ...

Achieve a top position in CSS layout without resorting to negative values

This may seem like a simple thing, but I'm struggling to achieve it without using negative values for padding-top. Here's how my site looks: Here is the CSS code I am using: .center { width: 1030px; margin: 0 auto; } .top-panel { backgr ...

Make sure to load the <img> html tag before implementing js masonry for optimal

I am facing an issue with jQuery Masonry as it arranges my 'bricks' immediately without waiting for images to load in. Additionally, I need the images to be responsive so I cannot define their height and width like this: <img src="asas" heigh ...

Connect different CSS variables within a related context

Looking to incorporate Font Awesome 5.10.2 Duotone icons easily into any HTML element. The icon element relies on HTML attributes that should correspond to a specific icon, with the mapping controlled by the CSS author. <x pay></x> <!-- Th ...

Utilizing the CSS properties of table-cell and float in a display

I've designed a header section, but I'm facing an issue. It looks good on devices with resolutions greater than 1020: https://i.sstatic.net/VlgmR.png https://i.sstatic.net/x3V15.png The problem arises on smaller resolutions: https://i.sstatic. ...

What is the best way to align checkboxes perfectly alongside the rest of the text within the text box?

I need the checkbox to be positioned under the text boxes in a aligned manner. Even though I used the CSS code below to align the text boxes, the checkboxes are not properly aligned: label { width:135px; clear:left; text-align:right; p ...

Retrieve form data (from a standard form submission) with jQuery

Within page A, I have a form containing 2 fields - one for the user and one for the password. The form's action directs to page B. Is there a way to use JavaScript to retrieve the form values from the request header when page B is loaded? Or is there ...

Issue with collapsing menu button in Bootstrap 5 navbar

I have followed a tutorial on Bootstrap from this YouTube video, but despite following it closely, the collapse button is not functioning as expected. I used a template from the Bootstrap website and ensured that all necessary JavaScript and CSS files are ...

Navigating through the conditional "where" clause in IndexDB for various browsers

I have successfully implemented indexdb because it provides support for all browsers. I have managed to add and retrieve data from indexdb, but now I want to implement a where clause condition. For example, I have fields like Product Name, Pathogen, Diseas ...

Tips for updating the content of multiple tabs in a container with just one tab in Bootstrap 4.x

I am attempting to create two tab containers, where one is used to describe the content of a set of files and the other is used as a list of download links for the described files. Initially, I tried controlling the two containers using just one tab. I ca ...

JavaScript: Deactivate radio buttons based on selected value

Utilizing radio buttons to schedule appointments in a PHP web application is my goal. Presented below is a selection of Radio Buttons, from which the user can pick one. The selected value will be stored in the database as an appointment date and time. &l ...

Javascript: Efficient ways to populate multiple inputs upon clicking

Is there a way to populate all input fields on my page with the id toinput using an onclick button? In this code snippet, only the first input field is currently being filled out. How can I fill out both of these inputs with just one click when launching ...

Why do my padding and font size fail to match the height of my container?

When setting the height of my boxes to match the height of my <nav>, I encountered overflow issues. Despite using a 10rem height for the nav and a 2.25rem font, calculating the padding as 10-2.25/2 didn't result in the desired outcome. Can someo ...

Displaying an HTML string on a webpage

I am developing a user dashboard using Django for a Python-based web application. This web application generates emails, and the HTML content of these emails is stored in a file (and potentially in a database table as well). As part of the dashboard's ...

When I tried to address one issue, my CSS ended up breaking. Any suggestions on how I can resolve the header

Edit: https://i.sstatic.net/kVeHk.jpg Picture 1 code: main.css body { font-family: arial; font-size: 14px; color: #1D2130; background-image: linear-gradient(top, rgb(200,225,245) 15%, rgb(240,240,240) 60%); // more CSS properties h ...