CSS styling not properly displaying image on mobile devices

I am in the process of constructing a website and I came across this page that has a feature similar to what I want to achieve: https://i.sstatic.net/E9k74.png

To understand how they built that feature, I examined the .css and HTML code from their webpage.

Here is my attempt:

https://i.sstatic.net/VgE1T.png

The problem arises when I try to view the site on a mobile phone - I struggle with hiding my image. Even if I use "hidden-xs" in the image div, the text alignment gets disrupted.

On the left side you can see what I am aiming for, and on the right side is my current result: https://i.sstatic.net/CW9Kn.png

HTML

<div class="white_bg">
    <div id="mobile-app-sections" class="container">
        <div class="container-medium">
            <div class="row">
                <div class="col-xs-5 into-row border app-image-wrap">
                    <img class="app-phone" src="img/device.jpg">
                </div> <!--col-->
                <div class="col-xs-7 into-row border">
                    <h2>foodpress in your mobile! </h2>
                    <h3 class="green-text">Get our app, it's the fastest way to order food on the go.</h3>

                    <div class="row border" id="getapp-wrap">
                        <div class="col-xs-4 border">
                            <a href="http://" target="_blank">
                                <img class="get-app" src="img/get-app-store.png">
                            </a>
                        </div>
                        <div class="col-xs-4 border">
                            <a href="http://" target="_blank">
                                <img class="get-app" src="img/get-google-play.png">
                            </a>
                        </div>
                    </div> <!--row-->
                </div> <!--col-->
            </div> <!--row-->
        </div> <!--container-medium-->

        <div class="mytable border" id="getapp-wrap2">
            <div class="mycol border">
                <a href="http://" target="_blank">
                    <img class="get-app" src="img/get-app-store.png">
                </a>
            </div> <!--col-->
            <div class="mycol border">
                <a href="http://" target="_blank">
                    <img class="get-app" src="img/get-google-play.png">
                </a>
            </div> <!--col-->
        </div> <!--mytable-->
    </div> <!--container-->
</div><!-- End white_bg -->

CSS

    /* CUSTOM CSS */

img{
    max-width:100%;
    height:auto;
}

.border{
    border:0px solid red;
}


.mytable{
    display:table;
    width:100%;
}

.mytable .mycol{
    display:table-cell;
}

#mobile-app-sections{
    padding-top:30px;
}

.container-medium {
    max-width:800px;
    margin:auto;
}

#mobile-app-sections h2{
    margin-top:22%;
}

#mobile-app-sections h3{
    margin:auto auto 25px;
}

#getapp-wrap2{
    margin:auto;
    width:300px;
}

#getapp-wrap2 img{
    max-width:130px;
}

#getapp-wrap2 .mycol{
    width:150px;
}

#getapp-wrap2{
    display:none;
}

I borrowed the HTML and CSS snippets from this site in an attempt to troubleshoot my issues.

What Could Be Going Wrong?

Additionally, the image I am trying to hide has the class name "app-phone," which I cannot locate in the source code (possibly the root of the issue?).

Thank you for your assistance!

Answer №1

Once the image is hidden, the text does not center properly because it still only occupies 7 out of the total 12 columns available. To ensure the text centers correctly on mobile devices, you should utilize all 12 columns and then limit it to 7 at the next standard breakpoint size (small).

<div class="hidden-xs col-sm-5 into-row border app-image-wrap">
    <img class="app-phone" src="img/device.jpg">
</div> <!--col-->

<div class="col-xs-12 col-sm-7 into-row border">

For more information: http://getbootstrap.com/css/#grid

Answer №2

When it comes to responsive design, xs is for screen sizes below 576px while sm is for sizes above 576px. Therefore, if you want your columns to display correctly, make sure to use sm instead of xs in your code. For example, using col-xs-6 will make a column 50% width on screens under 576px (like mobile), but if you want it to be 50% on tablets and desktops and 100% on mobile, you should opt for col-sm-6

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 align the button next to the textbox?

Is it possible to remove the space between a button and a textbox in ASP.NET so that they appear next to each other without any gap? If so, how can this be achieved? Here is my CSS code snippet: .input, .button { margin:-10px 0px 0px 0px; } This is my A ...

Developing an E-commerce Cart feature using AJAX, HTML5, and Jquery exclusively

I am looking to develop a Cart System using solely HTML5, AJAX, and Jquery without incorporating any server side scripting language like PHP or ASP.NET. The scenario I have is: "A designated HTML division displaying added products with their Name, Price, ...

What is the best way to include a Bootstrap CSS class in a select field using a loop within a Rails application?

Currently, I am dealing with a select field setup in the following way: <%= f.select(:avaliador_id) do %> <% @usuarios_array.each do |u| %> <%= content_tag(:option, u.first, value: u.last) %> <% end %> <% end %> My q ...

Chrome mobile's justify-content for space-evenly is malfunctioning

Experiencing an issue with the space-evenly value for justify-content on Chrome mobile, while it functions correctly on Desktop and Firefox mobile. A minimal example can be seen here: Example Having a flex container in a row direction aiming to evenly sp ...

What is causing the floated element to overlap the element below instead of vice versa?

div { background-color: #00FFFF; } p { width: 50px; height: 50px; border: 1px solid black; margin: 0px; } #p1 { background-color: red; float: left; } #p2 { background-color: green; } #p3 { background-color: orange; } #p4 { backgr ...

Customize the printing settings within bootstrap by modifying the background color from transparent to a solid color using CSS/SCSS

I am facing an issue with the bootstrap CSS/print feature. In the bootstrap CSS (reset.css) file, all styles are cleared for printing purposes. @media print { * { text-shadow: none !important; color: black !important; background: transparen ...

Internet Explorer Fails to Display CSS Background Images

Requesting assistance, The issue I am facing is that the background image is not displaying in Internet Explorer, although it appears perfectly fine in Safari. I have conducted thorough checks with W3C CSS validation and HTML validation, confirming that ...

Differences in Behavior of jQuery Element Styles in Firefox and Chrome When Modals Are Visible

I'm new to working with jQuery and JavaScript. Currently, on my website, I have implemented several unique modal/popups that are activated using a CSS :target selector, which changes their display property to block. Additionally, I am attempting to us ...

Is there a way to change the color of a single word without affecting the rest of the line?

https://i.sstatic.net/vFWgU.png I am encountering an issue where I only want the word "declined" to be color inverted, rather than the entire line. Can anyone provide assistance with this? .invert { background-color: white; filter: invert(100%); } ...

Item within text box remains untouched

I am working with a 1) Text field 2) Drop down list 3) List box I have written code to add the selected value from the drop down list to the list box and text field, but I'm having trouble removing the value from the text field. Can someone please he ...

An iframe perfectly centered both horizontally and vertically, featuring a 16:9 aspect ratio and utilizing the maximum screen space without any cropping

Specifications: It is mandatory for the iframe to be enclosed within a div container as shown in the code below. The container should have the flexibility to adjust to any valid width and height using the vw and vh viewport units. Check the code provided ...

Calculate the sum of hours worked in a day using pure JavaScript, no external libraries required

Hello, I'm new to this website and please excuse me if my English is not perfect, I am trying my best to communicate :) I have been working on a page that calculates the total hours worked in a day and this is what I have achieved so far until 15/06 ...

Tips for sending numerous forms simultaneously

There is an issue with my two forms that are submitting data. When I submit items to the cart, it only updates or inserts the quantity of the first item, not the selected item's quantity. Here is the Javascript code for multiple form submission: < ...

How can CSS animations be implemented on a diagonal path?

I have developed a unique CSS animation that adds a shiny effect to text. Currently, the effect only works horizontally. I am interested in exploring options to change the direction of the animation to create a diagonal shine effect. Below is the code I a ...

Discover the method for accessing a CSS Variable declared within the `:root` selector from within a nested React functional component

Motivation My main aim is to establish CSS as the primary source for color definitions. I am hesitant to duplicate these values into JavaScript variables as it would require updating code in two separate locations if any changes were made to a specific co ...

Modify the color of the 'li' element that shares the same attribute value as the current page

I am in the process of creating a website for an architecture company. Currently, I am working on a specific page which you can find here: . Each project falls into a category such as residential, commercial, or education. On each project page, I include t ...

Do attributes from our Angular app's <head> and <meta> tags get inherited by asynchronously pulled in HTML?

Within an Angular application, our index.html file contains a <head> tag where we define the charset: <head> <meta charset="utf-8"> </head> When a user navigates to a specific page, the component of that page makes an ...

The disappearing drop-down form issue arises when utilizing AJAX to fetch data from a MySQL database using a PHP file

Using AJAX to fetch data from a MySQL database via a PHP file and display it in a dropdown menu based on the user's initial selection is working smoothly. The second dropdown populates correctly as intended. However, an issue arises when an option is ...

Steps for linking two MySQL tables

I have a table named "products" in my MySqli Database. Products TABLE product_id | INT primary KEY product_name | VARCHAR(50) product_price | float When entering rows into the products table from PHP, I use the following code: mysq ...

How to Nest Div Elements in Bootstrap Grid System

I'm currently using bootstrap to create the structure for my website. However, I am facing an issue with arranging three div tags within one main div tag. Instead of appearing side by side, they are stacking on top of each other. <div class="col- ...