What is the best way to position the content on this page so that there is no horizontal scroll

Hey there! I'm currently working on a simple website using CSS flexbox, but I'm encountering an issue with my layout in About.vue. For some reason, this component is stretching out with a horizontal bar, even though it's only placed within the mainLayout.vue. I'm really struggling to figure out what's causing this problem. Does anyone have any ideas on how to fix it?

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

MainLayout.vue

<template>
  <div class="wrapper--main">
    <Navbar />
    <Hero />
    <main>
      <slot />
    </main>
    <Footer />
  </div>
</template>
<script lang="ts">
import Hero from "../components/Hero.vue";
import Footer from "../components/Footer.vue";
import Navbar from "../components/Navbar.vue";
import { defineComponent } from "vue";
export default defineComponent({
  components: { Navbar, Footer, Hero },
});
</script>
<style lang="sass">
@import "../styles/mainLayout.sass"
@import "../styles/variables.sass"
@import "../styles/utilitys.sass"
</style>

MainLayout.sass

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap')
*,
*::before,
*::after
    box-sizing: border-box
    margin: 0px
    padding: 0px

img,
picture,
svg
    max-width: 100%
    display: block
    object-fit: cover

img
    object-fit: cover
@media (min-width: 768px)
    html
        font-size: 130%

body
    font-family: 'Lato', sans-serif
    font-weight: 400
    line-height: 1.65
    max-width: 2000px
    background-color: hsl(var(--white))
    color: hsl(var(--text))

.wrapper--main
    display: grid
    grid-template-rows: auto 1fr auto
    min-height: 100vh

main
    display: grid
    gap: var(--size-fluid-6)
    margin-bottom: var(--size-fluid-5)
    margin-top: var(--size-fluid-5)

Index.vue

<template>
  <MainLayout><About /> </MainLayout>
</template>
<script lang="ts">
import MainLayout from "../layouts/MainLayout.vue";
import About from "../components/About.vue";
import { defineComponent } from "vue";
export default defineComponent({
  components: { MainLayout, About },
});
</script>
<style lang="sass">
</style>

About.vue

<template>
  <div class="about-container">
    <div class="wrapper gap">
      <div class="title-container--about gap--sm">
        <div class="title-wrapper">
          <h2 class="h2">lorem ipsum</h2>
          <p class="title-container--sm">
            Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolor
            iusto impedit molestiae quo, labore perspiciatis quia, deserunt quis
            nobis asperiores, delectus ut! Quaerat ut molestiae sunt ex
            molestias fuga quis. orem ipsum dolor sit amet consectetur,
            adipisicing elit. Dolor iusto impedit molestiae quo, labore
            perspiciatis quia, deserunt quis nobis asperiores, delectus ut!
            Quaerat ut molestiae sunt ex molestias fuga quis.
          </p>
        </div>
        <div class="arrow--map">
          <img class="icon--lg" src="../icons/arrow-map.svg" alt="" />
        </div>
        <div class="container-about-btn-map">
          <img class="icon--lg about-map" src="../icons/map.svg" alt="" />
          <button class="btn btn--primary about-btn">lorem ipsum</button>
        </div>
      </div>
      <img class="img-about only-desktop" src="../img/about.jpg" alt="" />
    </div>
  </div>
</template>
<script lang='ts'>
import { defineComponent } from "vue";
export default defineComponent({});
</script>
<style lang="sass">
.title-container--sm
  width: var(--size-fluid-10)
  flex-grow: 0
.about-map
  margin-right: auto
.about-btn
  margin-right: auto
.container-about--btn-map
  display: flex
  flex-direction: column
  justify-content: center
  width: 200px
.gap--sm
  gap: var(--size-fluid-4)
.title-container--about
  display: flex
  flex-direction: column
.arrow--map
  display: flex
  justify-content: center
.gap
  gap: var(--size-fluid-8)
.about-container
  margin-left: var(--size-fluid-7)
  margin-right: var(--size-fluid-7)
@media (max-width: 1440px)
  .only-desktop
    display: none
</style>

Answer №1

Consider including the following CSS:

html, body
    ...
    max-width: 2000px
    width: 100vw
    overflow-x: hidden

If the above method does not work, you can try using the overflow-x property as a last resort.

Explanation of why this solution is effective

By setting a max-width for the body element, you are ensuring that the content does not exceed a certain width. Since the default width of the html element is the viewport width, when the body content expands vertically, the body element will also increase its width to accommodate it, potentially overflowing the html element.

Setting width: 100vw ensures that the body element's width matches that of the html element and does not go beyond it.

The use of max-width becomes more relevant on larger screens like desktops, where you may want to limit the width of the content. However, this may not be ideal for all cases as it can result in all content being confined to one side of the screen, affecting elements like the navbar which may not span the full width as desired.

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

Designing multiple button actions in v-card-actions in Vuetify: A step-by-step guide

Trying to streamline the v-card-actions on my Vuetify v-cards. My aim is to center the test button within the v-card and position it above the like and share "footer" buttons. I want the like and share footer buttons to be at the bottom of the v-card with ...

What is the best method to collect information from multiple AJAX requests?

In addition to synchronous AJAX calls, what is the most effective approach for handling a situation like this? var A = getDataFromServerWithAJAXCall(whatever); var B = getDataFromServerWithAJAXCallThatDependsOnPreviousData(A); var C = getMoreDataFromServe ...

"Losing focus: The challenge of maintaining focus on dynamic input fields in Angular 2

I am currently designing a dynamic form where each Field contains a list of values, with each value represented as a string. export class Field { name: string; values: string[] = []; fieldType: string; constructor(fieldType: string) { this ...

Every time I try to create a new React app, I consistently run into the same error

I keep encountering this error every time I try to create a React app using create-react-app. ...

Enabling auto-expansion for textareas with every keystroke

Currently, I have implemented the following script: jQuery.each(jQuery('textarea[data-autoresize]'), function() { var offset = this.offsetHeight - this.clientHeight; var resizeTextarea = function(el) { jQuery(el).css('h ...

A web application using JavaScript and Node.js with a focus on creating a REST

After extensive research, I am eager to develop a web application using JavaScript and Node.js with an SQL back-end. However, the abundance of frameworks and tools available has left me feeling overwhelmed. While I have identified some that I would like to ...

Transformation of JSON output from the controller into a sophisticated entity: Razor

I have a partial view called "_SearchPanel" which includes a dropdown list for selecting years, a multiselect control for classes (along with some other drop downs - omitted), and a search button. My goal is to only refresh/update the classes list when ch ...

Any methods for integrating js.erb files in Ruby on Rails 7?

I've been searching for a while now on how to integrate js.erb files into my Ruby On Rails 7 project, but I haven't been able to find any helpful information. Have js.erb files become obsolete in Rails 7? If so, is there a way to include partials ...

Runtime.UnhandledPromiseRejection - Oops! Looks like we're trying to read properties of something that doesn't exist (specifically 'headers')

I'm facing an unexpected error that has left me puzzled. Let me walk you through what I am trying to accomplish: The task at hand involves fetching data from one API and then transmitting it to another. This process is executed as a background-funct ...

What is the best method for transmitting all parameters via a URL?

$(document).ready(function () { $("#submitButton").click(function () { var name = $("#name").val(); var age = $("#age").val(); var gender = $('input:radio[name=gender]:checked').val(); v ...

Navigating through an array containing references to object IDs with Mongoose

In my meanjs project, I am receiving user input on the server with a specific request body structure: { transaction: { heading: '', items: [Object] }, something: {}, somethingAgain: {} } The format of the items a ...

Having trouble with submitting data in an ExpressJS POST request while using mongoose?

As I embark on building my first express.js application, I encounter my initial obstacle. The setup is rather simple. Routes in app.js: app.get('/', routes.index); app.get('/users', user.list); app.get('/products', product. ...

What is the best way to pass data from the server to a Vue CLI application?

I am looking for a way to connect my Vue CLI app to a server back-end. The server will send a view template along with data payload, and I need to inject that payload as JSON into the Vue app as a data property. Here is a snippet of the index.html file ge ...

How can we retrieve the coordinates of the top-left and bottom-right corners based on the given bounds

Looking to retrieve the X and Y coordinates of the top-right & bottom-left corners of a text box based on the bound value. For instance: [84,672][1356,889] Is there a straightforward JavaScript function that can efficiently extract these values into sepa ...

Using AngularJS to send a $http.post request with Paypal integration

This form utilizes the standard PayPal format for making purchases. <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<a href= ...

Using addClass and removeClass functions in JQuery when selecting a radio button

I am facing an issue with my radio buttons being displayed as images. When a picture (radio button) is selected, I want the other pictures to become hidden. To achieve this, I plan to add a class to the checked picture and then add another class to the unc ...

Tips for setting up listeners across multiple modules using socket.io

Last year, I created a multiplayer game using node.js and socket.io. Now, as part of my efforts to enhance the game, I am working on breaking down the code into modules. Currently, I am utilizing expressjs 4.4 along with socket.io 1.0. One challenge I enco ...

What sets index.js apart from page.js in next.js?

https://nextjs.org/docs/pages/building-your-application/routing/pages-and-layouts While reading through the next.js documentation, I came across an interesting point. The documentation mentions that index.js serves as the root of the directory. This mean ...

Display the JSON information within a text input field using React JS

Below is the code I have written in the componentDidMount function: componentDidMount: function() { var url = document.URL; var currentId = url.substring(url.lastIndexOf('?') + 4); // Extracting the current ...