Content on the website that adjusts to different screen sizes horizontally, while maintaining a

Currently, I am working on developing a responsive website using Bootstrap. While the layout works well when resizing the window horizontally, there is an issue with vertical resizing. I do not want the height of the elements (such as Bootstrap columns, images, and divs) to change when the window is resized vertically. Despite searching for a solution, I have not found one yet. If anyone has suggestions on how to address this problem, please let me know!

Update: To provide a visual reference, I have included a couple of images demonstrating the undesired behavior.

Here is a snapshot of the section of the site in question before vertical resizing.

And here is the same section after vertical shrinkage, where the text spills out of the containing div. My goal is to maintain the height of the div during vertical shrinking while adjusting its width during horizontal resizing.

I'm relatively new to web development and posting questions online, so feel free to ask for more details if needed!

Update 2: Added snippet of my code below

body {
  background-color: #f4f4f4;
  color: #111111;
  height: auto!important;
  min-height: 100vh;

#home-content {
  text-align: center;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  margin: 0;
  padding-top: 7.5vh;
}

.col-content {
  background-color: #fdfdfd;
  height: 40vh;
  margin-bottom: 5vh;
  margin-left: 1vw;
  box-shadow: 1px 1px 3px #555555;
}

#intro-content {
  padding: 5px 10px 5px 10px;
}

h2 {
  font-size: 200%;
  margin-top: 2vw;
  margin-bottom: 1vw;
  font-family: Perpetua;
  text-align: center;
}

#intro-hr {
  background-color: #444444;
  height: 1px;
  margin: -5px 0 5px 0;
}

#intro-text {
  text-align: left;
  margin-top: 1vw;
  font-family: verdana;
  font-size: 16px;
}
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="viewport" content="width=100px, initial-scale=1, maximum-scale=1">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  <link href="css/styles2.css" rel="stylesheet" type="text/css" />

  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="js/script.js"></script>

</head>


<body>

  <div id="home-content" class="container-fluid">
    <div class="row">
      <div id="intro" class="col-lg-6">
        <div id="intro-content" class="col-content top left">
          <h2> Title </h2>

          <hr id="intro-hr">

          <p id="intro-text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras placerat molestie volutpat. Nam gravida tortor id tellus pulvinar sodales. Duis sodales sagittis ex, a ultricies lacus tempus vel. Maecenas lobortis venenatis sem. Nulla at odio vehicula, volutpat
            quam eu, fermentum dolor.
          </p>
        </div>
      </div>

      <div id="contact" class="col-lg-6">
        <div id="contact-content" class="col-content top">

        </div>
      </div>
    </div>

Answer №1

To achieve equal column sizes, consider using auto for col-content height combined with a min-height attribute. However, the root cause of the issue lies in setting fixed heights.

Answer №2

One possible solution could be setting the height to 100vh, as this ensures it takes up 100% of the viewport's height.

Answer №3

To ensure the proper functionality of this CSS code, it is recommended to remove the 40vh portion as per your requirement. The height will remain consistent at 40vh even when adjusting the width of the viewport, resulting in a proportional adjustment of the text size. When no specific height is provided, the auto setting automatically assigns an appropriate height.

.col-content {
  background-color: #fdfdfd;
  margin-bottom: 5vh;
  margin-left: 1vw;
  box-shadow: 1px 1px 3px #555555;
}

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

Leveraging both onmouseover and onmouseout for container expansion

My goal is to utilize JavaScript along with the HTML events "onmouseover" and "onmouseout" to create a dynamic container. Essentially, I want the container to act as simply a heading when the mouse is not hovering over it, but expand to display additional ...

Guide to creating a clean and minimalistic tabbed menu using CSS

Looking for CSS code for the tabbed menu shown above. I've tried several options but haven't been able to achieve the exact design I want. Here is the directive, HTML, and CSS code provided: <div id="tabs"> <ul> <li> ...

Executing various onclick functions - Text Display

I've developed a code that includes onclick events to change the color of buttons and prevent them from being clicked twice. Additionally, I am looking to have data added to a table column/row when a button is clicked. For example, clicking button 3 s ...

Overriding Styles Set by an External CSS file

Let's assume that I have two different style sheets set up on my webpage: site.css: .modal { position: absolute; width: 200px; ... } ... reset.css: .reset * { position: static; width: auto; ... } Unfortunately, I don ...

problems with implementing nested columns in Bootstrap

I'm dealing with a container filled with nested columns. Strangely, the columns are now being displayed one after the other instead of side by side. I've been trying to figure out what's causing this issue. Take a look at my attempt to solv ...

Utilize PHP to sift through HTML content and extract a specific tag

How can I extract a specific form using PHP? $url = '<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <div class="waitmsg" id="WaitMessage ...

Optimize the css file by updating it and minifying the content

Recently, I created a website for a client using PHP, HTML, Javascript, and CSS. Initially, I utilized SASS to streamline my styling process. However, the client now requests the ability to modify typography and main colors on their own. While I can easi ...

Textfield with autocomplete dropdown

I have a text field on my website that needs to work as an autocomplete box. I have included the following code in the "headerbar" section of my page: Find :<input type="text" class="input2" style="margin-bottom:0px;" id="customersearchfield"> < ...

Divs that are 30% of their parent's width will not align vertically and will not fit in a parent div that is 100% width

I am attempting to vertically center the three child-divs <div class="section"> as 3 rows in one column within <div class="container_page_2">. When I refer to vertical alignment, I mean having an equal distance between the top of the page and ...

Managing the intersection of div elements

Can someone help me make the inner part of the red circle white, overlapping with the blue circle and transparent for the rest to reveal the green color underneath? If anyone has a solution, I would greatly appreciate it. #bigCircle { display: flex ...

Tips for updating the default value of an HTML <select> tag using a customized <select> option

I'm struggling to update the value of my <select><option value=""></option></select> based on a custom select option I created. Customizing select options using JS and jQuery is necessary since they can't be easi ...

How to stop Bootstrap collapsible items from "shifting"

I recently integrated a Bootstrap collapse plugin to manage my list of common inquiries: https://jsfiddle.net/2d8ytuq0/ <ul class="faq__questions"> <li> <a href="#" data-toggle="collapse" data-target="#faq__question_1">..</a> ...

creating a new page upon clicking a div element

I need assistance in creating an effect similar to the one found on this website - where clicking on a div opens a new page. ...

Unexpected border-bottom styling issue observed on adjacent div elements

This is my unique code: <!DOCTYPE html> <html> <head> <style> </style> </head> <body> <div style="border-bottom:1px solid black"> <div style="width=50%;float:left">A new paragraph with u ...

onpageshow event behaves as expected exclusively on webkit browsers (triggers function solely when visible on the screen)

I am inserting an HTML file using an object tag. The encompassing div of the object tag is hidden with a display:none property. However, I encounter an issue where the onpageshow event that I placed on the body tag of the HTML object behaves differently a ...

Discover a class located following a specific element even when they are not directly related

There is a group of elements all with the class month. Some of them also have the class cal, while only one has the class today. The goal is to locate the first element with the class cal, but only after finding the element with the class today. The chall ...

How can CSS be utilized to customize a data table by removing borders and adjusting the height of data cells?

Struggling with custom styling a Vuetify data table to remove borders and adjust cell height? Check out this CodePen example. new Vue({ el: '#app', data() { return { headers: [{ text: 'Dessert (100g serving)', ...

What could be causing the favicon in my Next.js application to not function properly?

My favicon doesn't seem to be working properly. I've saved the favicon file as favicon.ico in the /public directory and have included a reference to it in the <Head> section of my pages (which are located in the /pages directory), but it s ...

How can I place the current date inside a red dashed box with text using JavaScript?

Let's Solve This: The date currently appears in the top left corner without any special formatting. My goal is to make it bold, red, and encased in a dashed-red border. I have identified the element by its ID "datetext", corresponding to a "p" tag w ...

Choosing from all videos on YouTube

I am currently attempting to extract the watch URLs of all uploaded videos from the video manager on YouTube. How can I go about selecting all videos displayed on the page? From my observation, each video contains a vm-video-title-content yt-uix-sessionlin ...