Struggling to achieve a responsive design for a website on smaller devices with Twitter Bootstrap

I'm currently working on a school project and I'm fairly new to Bootstrap. I've been encountering some challenges with scaling the website for different resolutions. Whenever I switch to mobile view, the images overlap the text. I would greatly appreciate any assistance in resolving this issue.

<body>
  
<div class="container">
    
<nav class="navbar-fixed-top sticky-top navbar" style="width: 100%; background-color: white; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);"> 
    
    <div class="navbar-header">
    
        <a class="navbar-brand"><img src="transferir.png" alt="" style="height: 65; width: 60px"></a>
        
    </div> 
    
    <div>
        <ul id="menu">
            <li><a href="#home">Home</a></li>
            <li><a href="#sobre">About</a></li>
            <li><a href="#features">Features</a></li>
            <li><a href="#contact">Contact Us</a></li>
        </ul>    
    </div>
        
</nav>


    
<div class="site-index">
    
    <div id="home" class="block home-block">
        <div class="container">
            <div class="col-sm-6  left-block">
                <div class="text-centered">
                    <h1>Texter</h1>
                    <p class="info-text">Send text messages, voice messages, video messages or video call with all your friends and family easily, quickly and securely.</p>
                    
                    <p class="Medium-text">Download Coming Soon</p>
                    <a href="https://play.google.com/?hl=pt-PT" target="_blank"><img src="playstore.png" alt="Playstore" class="d-img"></a>
                    <a href="https://www.apple.com/pt/ios/app-store/" target="_blank"><img src="appstore.png" alt="Apple App Store" class="d-img"></a>
                </div>
            </div>
            <div class="col-sm-5  right-block">
                <img src="phones.png" style="height: 350px; float: right; vertical-align: middle; width: auto !important; position: relative">            
            </div>   
        </div>
        <hr class="sombra">
    </div>
</div>

Css

html{
   scroll-behavior: smooth;
}

body{
    padding-top: 1%;
    font-family: 'Lato', sans-serif;
}

.block{
    padding: 35px;
}

.home-block{
    min-height: calc(100vh - 90px);
}

#home .container{
    height: 500px;  
}

.left-block{
    text-align: center;
    top: 30%;     
}

.right-block{
    bottom: 35%;
    margin-left: 25%;
}

.container{
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

Desktop View

Mobile View Issue

Answer №1

To start, it seems like you may have overlooked adding the

<div class="row"></div>
wrapper inside your
<div class="container">...</div>
element, as stated here.

Additionally, I highly advise against excessive use of CSS properties such as position: relative/absolute,

top: ...; left: ...; right: ...; bottom: ...
, as they can disrupt the native document flow of CSS and should be employed only when necessary.

If time permits, I recommend delving into this series of articles on CSS layout: CSS layout

I disabled most properties of that nature, resulting in a noticeable improvement:

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

This response would simply be general advice without some coding assistance, so here are some fixes provided below.

Begin by deactivating these properties using DevTools:

.home-block{
    /* min-height: calc(100vh - 90px); */
}

#home .container{
    /* height: 500px; */
}

.left-block{
    /* text-align: center; */
    /* top: 30%; */
}

.right-block{
    /* bottom: 35%; */
    /* margin-left: 25%; */
}

Correcting Bootstrap markup:

<div id="home" class="block home-block">
    <div class="container">
        <!-- Added this wrapper, changed .col-* classes to responsive -->
        <div class="row">
            <!-- Removed .left-block class -->
            <div class="col-sm-12 col-lg-6  left-block">
                <div class="text-centered">
                    <h1>Texter</h1>
                    <p class="info-text">Send text messages, voice messages, video messages or video call with all your friends and family easily, quickly and securely.</p>
                    <p class="Medium-text">Download Em Breve</p>
                    <a href="https://play.google.com/?hl=pt-PT" target="_blank"><img src="playstore.png" alt="Playstore" style="height: 40px;"></a>
                    <a href="https://www.apple.com/pt/ios/app-store/" target="_blank"><img src="appstore.png" alt="Apple App Store" style="height: 40px"></a>
                </div>
            </div>
            <!-- Removed .right-block class, added .text-centered class -->
            <div class="col-sm-12 col-lg-6 text-centered">
                <!-- Removed inline styles (bad practice), changed "height" to be an attribute -->
                <img src="phones.png" height="350">            
            </div>
        </div>
    </div>
</div>

After making these adjustments, the image now appears correctly positioned in relation to the button at the top:

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

To address the navigation bar, consider disabling padding-left specifically for the ul#menu element:

#menu {
    padding-left: 0;
}

Although this resolves the issue on sm resolutions, further adjustments may be needed for resolutions below approximately 520px where the navigation menu wraps under the logo. Contemplate possible solutions either mentally or through a tool like before implementing your chosen approach.

Answer №2

If you want to make your website responsive, consider using the following code:

<head>
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>

For more information, take a look at this resource and this one

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 apply different styles to alternative children within a dynamically generated list?

I am currently implementing the following code snippet: $('.js-toprow:nth-child(even)').css("background:", "#ddd"); $('.js-toprow:nth-child(odd)').css("background:", "#ff0000"); Within the function: function resetSlides() { conta ...

Determine browser compatibility by evaluating the DOM Level

Can we easily determine which browser versions and above are compatible with a certain DOM level? ...

Utilizing the output of a callback function to execute res.render in a NodeJS application

Currently, I am utilizing oracledb for node in order to retrieve data from the database. Once the data is fetched, my goal is to transmit it to the client side using render() in express JS. Below is an example of the code structure: config.js module.expo ...

Is it possible for an SVG to derive its dimensions from the containing element?

I am currently in the process of transitioning a Vue/Vuetify application from using web fonts for Material Design Icons to utilizing SVG icons instead. With the web font, an example of a heading that includes an icon looks like this: <template> &l ...

I am having trouble displaying my mysqli table correctly. I could use some help troubleshooting my code as I am unable to locate the error

After implementing Bootstrap, I am facing an issue with the table display on my new page. The code works perfectly fine on the old page, but for some reason, it's not showing correctly on the new one. Upon inspection, I suspect that mysqli_close and a ...

What could be causing the issue with my query that is preventing it from properly displaying information in

Even though I can successfully connect to my database, it keeps pointing out an issue with my query. However, I'm certain that the query is correct as I tested it in my phpMyAdmin console and got the desired results. It's been a while since I wor ...

Move your cursor over the image to see a different image appear

I am facing an issue - I'm attempting to make image hover affect another hover <img id="1" src="#" /> <img id="2" src="#" /> #1 {width:20%; opacity:0.5 } #2 {width:80%; position:absolute; display:none; } I have experi ...

AngularJS written plugin in Javascript

I developed an app using Rails and AngularJS. A startup has reached out to me about transferring the technology to their website, but they have limited tech resources. The goal is to create a seamless integration process. The idea is to make it similar to ...

Using AJAX to submit a form to a CodeIgniter 3 controller

I am working on adding a notification feature and need to run an ajax query through the controller when a button is clicked. Here's the script I'm using: $('#noti_Button').click(function (e) { e.preventDefault(); ...

Tips for submitting a form and retrieving session count without the need to refresh the page after submitting the form

I have set up a form that includes hidden input fields to send data to a PHP script. The script stores the values in an array of sessions by using AJAX to reload the page. Once the data is submitted successfully, an HTML alert message is displayed in <p ...

Accessing data returned from JSON in JQuery beyond the code block required

Is there a way to access returned JSON data outside of the JQuery getJSON method? For example: var price = ""; $.getJSON("../JSONDeliveryPrice", null, function (data) { price = eval(data.price); }); console.log(price); Unfortunately, this code does not ...

What is preventing me from retrieving the data stored in my JSON?

My PHP code snippet involves checking if POST data is not empty and the action is 'edit'. If this condition is met, it fetches data from the database based on the selected IDs and prepares a JSON response. if(!empty($_POST)&&($_POST[&apo ...

Chrome displays the page layout differently upon initial loading

https://i.sstatic.net/GhfJc.pngI am currently seeking a developer position and have created a personal website to showcase my skills to potential employers. However, I have encountered a bug that only seems to affect Chrome browser. When the page is first ...

Retrieve the property type for the specified object

Imagine we have a class with properties like this export class Person { constructor(name: string, age: number) { this.name = name; this.age = age; } public name: string, public age: number } const person = new Person(); Is there ...

Facing a selection list issue on a web application built with Flask and Vue.js

I'm trying to integrate Flask and Vue.js together, but I've encountered an issue with my select element. The following code snippet is present in my HTML file: <div class="col-sm-10"> <select class="form-select" v-mod ...

Enhancing Plotly Graphs with Custom Node Values

Encountering an issue while attempting to assign values to nodes on a plotly graph. Code: <html> <head> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <style> .graph-container { ...

Storing data locally and replacing the current URL with window.location.href

My course mate and I are working on writing a code that saves an order to local storage and redirects to an order page when the order button is clicked. However, we are facing issues where clicking on the order button doesn't register in the applicat ...

JavaScript table search feature for novices - finding results

I am relatively new to this, but I am working on improving the workflow within my company. I found some code at this link in order to create an internal site for searching current part numbers. However, my employees are looking for parts based on descripti ...

"What could be the reason for web3.eth.getAccounts() method returning an empty array when used with console.log

Upon executing web3.eth.getAccounts().then(console.log);, I encountered an empty array and also received a warning stating ./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression. The project began w ...

Encountering naming problem with ng-model, attempting to create an array but receiving a hash instead

Trying to create an array using ng-model, <div ng-repeat="n in [1, 2, 3]"> <input type="text" class="form-control" ng-model="headers[$index].key"> <input type="text" class="form-control" ng-model="headers[$index].value"> </div> ...