align the bootstrap when the screen resolution is less than 900 pixels

As a newbie in web development and Bootstrap, I'm working on creating a responsive website. Everything was going smoothly until I encountered an issue when transitioning from desktop to mobile view. I have three buttons aligned in a row on desktop, but I want them to be vertically stacked on top of each other in mobile view. The alignment is the problem here. I have attached a photo showcasing the issue along with my HTML and CSS code. Any help or advice would be greatly appreciated! https://i.sstatic.net/gJ2VJ.png

body {
  background-color: black;
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url("../Bloc\ Nisipari/View03.jpg") no-repeat center center fixed;
  -webkit-background-size: cover;
  /* For WebKit*/
  -moz-background-size: cover;
  /* Mozilla*/
  -o-background-size: cover;
  /* Opera*/
  background-size: cover;
  /* Generic*/
}

.container {
  color: white;
  font-family: 'montserrat';
  src: url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf");
  margin-top: 200px;
}

.img {
  width: 500px;
}

.textlogo {
  width: 400px;
}

.btn {
  --bs-btn-border-color: transparent;
  --bs-btn-border-width: none;
}

... (more CSS code here)

@media only screen and (max-width: 900px) {
  .container {
    color: white;
    font-family: 'montserrat';
    src: url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf");
    margin-top: 100px;
  }
  .text-center {
    display: block;
    text-align: center;
  }
}
<!doctype html>
<html lang="en>

... (more HTML code here)

</html>

Answer №1

Issue resolved! After troubleshooting, it was discovered that the problem stemmed from specifying a fixed width of 500px for the logo in the .css file, exceeding the dimensions suitable for a mobile phone. By adjusting the width to a percentage, in this case 70%, the logo now scales appropriately on the screen with the other elements aligning correctly.

Sharing this solution in hopes of assisting others facing a similar issue!

Answer №2

If I understand your issue correctly, I have a solution for you. The reason your buttons are not aligned to the center is because of the class textLogo, which has a static width parameter of 400px. You can try giving it a new value in @media or use the clamp() function for the width.

styles.css

.textLogo{
   width: clamp(33%, 400px, 88%)
}

The clamp() function will set the width to 33% if the screen is too big, 400px if it's greater than 33%, and 88% if it can't fit properly. Feel free to adjust the values and experiment with them. Good luck!

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

Switching off toggle does not switch back to primary theme when clicking again for the second time

When I click the button for the first time, it changes the theme. However, when I click it a second time, nothing happens; it seems like it's stuck on the second theme forever. It should change themes with every click. Can someone please help me with ...

What is the best way to center text within a div that is wider than 100%?

On my webpage, I have a header set to 100% width and text positioned on the banner. However, when zooming in or out, the text's position changes. How can I ensure that the text stays in place regardless of zoom level? Example: jsfiddle.net/5ASJv/ HT ...

Float a div within text to be positioned vertically

Is there a way to use only CSS to create an article that includes a featured quote section starting around 50px from the top? The section should be half the width of the page with text wrapping around it at the top and bottom. Currently, I am using the fl ...

Tips for resizing images to fit the parent container dimensions

After uploading an image, I needed to adjust its dimensions. The original image was 450x700, while the parent container was 400x400. Using 'object-fit' helped fit the image to its parent container while maintaining its aspect ratio. However, I r ...

Step-by-step guide to implementing a sticky header while scrolling

How can I implement a fixed header on scroll, like the one seen on this website: www.avauntmagazine.com Here is the HTML for my header: <div class="bloc bgc-wild-blue-yonder l-bloc " id="bloc-1"> <div class="container bloc-sm"> &l ...

The theme font fails to take effect on the paragraph

As a novice in HTML and CSS, I attempted to use the "Roboto Condensed" font from a WordPress theme for my entire site. Although I successfully implemented this custom font for a menu, I encountered difficulties when trying to apply it to paragraph elements ...

The sidebar.querySelector method is not working as expected

Attempting to assign an 'active' class to the clicked 'nav-link' element in order for it to stay active on the next page the user navigates to. Encountering an issue with sidebar.getElementsByClassName is not a function showing up in t ...

What is the best way to play a random song when the user clicks a button?

My goal is to develop a website where users can click on an image and have a random song play from a playlist. I currently have a functioning code that activates one song, but it fails when adding multiple songs to the mix. <html> <head> ...

Commence {{@index}} at 1 instead of 0 in Handlebars, without any template specified

Currently, I am utilizing the @each loop to go through items but would like to start with an index of 1 instead of 0. I attempted to resolve this by including the following code snippet: var Handlebars = require('handlebars'); Handlebars.regist ...

What's the best way to ensure an endless supply of copied elements with identical classes to the clipboard?

Here is a snippet of my HTML code: <Div Class='POSTS'> <Div Class='POST'> <Div Class='CONTENT'>Text1</Div> </Div> <Div Class='POST'> <Div Class=&apos ...

Utilize the Bootstrap grid layout to create space for empty columns on the left-hand

Is it possible to use CSS to ensure that empty columns in a predefined bootstrap grid are on the left rather than the right, without manually adding empty entries into the left hand columns? For example, if the column count is 4 (col-xs-3) and there are 5 ...

Is there a way to retrieve files stored on my hard drive within a webpage?

I have a large number of files stored on my hard drive, all following the same format, 2014.C1.012.012 - full name of the file. They each have unique numbers and names. I want to create a local webpage where I can organize these files into a table w ...

Timer Does Not Appear to be Counting Down

I recently added a countdown clock to my website, but I'm having an issue with it not updating in real-time unless the page is refreshed. I'm not very familiar with javascript, so I found some code online and made some modifications myself to sui ...

Create a moving background gradient with styled-components

Currently, I am working on setting the background of the <Paper /> component using Material-UI version 1.0.0-beta.25 to display a gradient of colors. The colors are dynamically added by clicking the Add button and selecting one from the color picker. ...

Error: The term "Image" is unrecognizable

I'm in the process of creating a website where I want to display images via links. If the image is missing or only 1 pixel wide, I need the site to show an alternative image. My technology stack includes Jade/Pug and JS. Before rendering the links on ...

CSRF validation did not pass. The request has been cancelled. The failure occurred due to either a missing or incorrect CSRF token

Upon hitting the submit button in the login form, I encountered the following error message: Forbidden (403) CSRF verification failed. Request aborted. CSRF token missing or incorrect. settings.py MIDDLEWARE = [ 'django.middleware.security.Secur ...

Could there be a scenario where the body onload function runs but there is still some unexec

I am feeling confused by a relatively straightforward question. When it comes to the <body> tag being positioned before content, I am wondering about when the body onload function actually runs - is it at the opening tag or the closing tag? Additio ...

Troubles with Flex wrap in CSS3 on iOS 10.3.2 browsers (Chrome and Safari)

Before sending me to other similar questions, keep in mind that I have already gone through them, attempted the solutions, and they are not resolving my issue. The problem I am encountering involves the flexbox layout. I am using the flexbox layout for ce ...

Issue with php's mysql_fetch_assoc() function

Seeking to fetch data from a function that holds my query. The retrieved data is sent back to the main page for printing using a while loop but encountering an error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given ...

What is the best way to utilize flex for resizing items proportionally?

Within the following script, I am emulating a stepper using row and col. It appears satisfactory. Nevertheless, when the page is viewed on wide screens (such as lg and xl), the spacing between the steps is excessive. Essentially, the stepper occupies the ...