CSS Table - Content on the Right side extending beyond the browser boundaries

I've been facing a challenge while working on our company's website this morning. I have formatted the page into two cells, one on the right and one on the left. The cell on the right contains an image that is around 790 pixels wide. However, when I shrink the browser window to a certain point where it no longer fits, the entire cell jumps below the first cell. How can I prevent this from happening?

Code snippet...

xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Test
</title>
<link href="StyleSheet1.css" type="text/css" rel="Stylesheet" />
</head>
<body>
<form name="form1" method="post" action="default.aspx" id="form1">
    <div>
        <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTg2ODI4NzA2OWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFCUNoZWNrQm94MU+tEbqmFYLAUCuNpKlG5GJdxlTP" />
    </div>

    <div>
        <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBwKUzskuAuzRsusGAoznisYGAuzR9tkMAuzRirUFAoLk17sJArursYYIEh1rVMqwd3ohPqFy9J1P74IvCz4=" />
    </div>
    <div style = "padding-left:15%;">
        <div class = "header">
            <img src="images/logoclr.bmp" style="height:56px;width:253px;border-width:0px;" />
            <input name="TextBox1" type="text" id="TextBox1" style="width:414px;" />
            <input type="submit" name="Button1" value="Search" id="Button1" />
        </div>
        <br /><br /><br /><br /><br />
        <div class="loginSide">
            <div class = "internalBox">
                Log On To Invoice Viewer
            </div>
            <br />
            <span>Login ID:</span>
            <br />
            <input name="TextBox2" type="text" id="TextBox2" />
            *<br />
            <br />
            <span id="Label1">Password</span>
            <br />
            <input name="TextBox3" type="text" id="TextBox3" />
            *<br />
            <br />
            <input id="CheckBox1" type="checkbox" name="CheckBox1" />
            Remember my Login ID<br />
            <br />
            <div style="padding-left:20px;"><input type="submit" name="Button2" value="Login" id="Button2" /></div>
            <br />
        </div>
        <div class = "imageSide">
            <img src="images/1_back11.jpg" style="border-width:0px;" />
        </div>
    </div>
</form>
</body>
</html>

CSS:

body {
    background-color:rgb(227,227,225);
    font-family:Verdana;
    font-size:.8em;
    margin-left:auto;
}

.loginSide {
    float:left;
    border-width:1px;
    border-right:0px;
    border-color:rgb(186,107,255);
    border-style:solid;
    width:275px;
    height:292px;
    padding:10px;
    background-color:rgb(223,232,237);
}

.imageSide {
    border-width:1px;
    border-color:rgb(186,107,255);
    border-style:solid;
    width:792px;
    padding:10px;
    background-color:rgb(223,232,237);
    float:left;
}

.internalBox {
    padding-left:50px;
    padding-right:50px;
    padding-top:5px;
    padding-bottom:5px;
    background-color:rgb(54,113,109);
    color:White;
}

Answer №1

To ensure that the image div does not wrap, consider setting an id for the main wrapping div (for example,

<div id="main-wrapper" style="padding-left:15%;">
) and create a CSS selector to define a minimum width:

#main-wrapper {
    min-width: 900px;
}

Choose the width based on the minimum size where the image div does not wrap. Once you have a selector for the main wrapper, you can also move the padding-left styling into the CSS instead of inline.

Check out this sample fiddle for reference

Answer №2

One way to create responsive cells is by making the width dynamic. By using a percentage instead of a fixed width, the cells will adjust automatically based on the window size.

.imageSide
{
border-width:1px;
border-color:rgb(186,107,255);
border-style:solid;
width:70%;
padding:10px;
background-color:rgb(223,232,237);
float:left;

}

.loginSide
{
float:left;
border-width:1px;
border-right:0px;
border-color:rgb(186,107,255);
border-style:solid;
width:30%;
height:292px;
padding:10px;
background-color:rgb(223,232,237);
}

Answer №3

Make sure not to specify the width for the imageSide, as it should adapt to the remaining width of the browser window, while the loginSide should maintain its fixed width.

Check out this example for reference.

Also, instead of using float: left for both loginSide and imageSide, apply it only to loginSide; imageSide will adjust automatically.

Here is the updated version of the example.

Alternatively, if you prefer minimal changes to your existing code, I have also made adjustments for you. :)

Take a look at the second version of the example where imageSide has a width of 792px.

Cheers.. :)

Answer №4

After some troubleshooting, the solution became clear by enclosing the image within this div:

<div style="overflow: hidden;">

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

Prevent a div from being displaced by the transform property once it reaches the window's border

Is it possible to prevent the viewer I created using CSS transform from moving when its borders reach the window borders? Should I consider using a different method instead? If you'd like to see the code, you can check it out here. var x=0, y=0 ...

What could be causing the if statement to evaluate as false even though the div's style.display is set to 'block'?

Building a react application using createreactapp and encountering an issue with an if statement that checks the CSS display property of a div identified as step1: const step1 = document.getElementById("step-1") if (step1.style.display === 'blo ...

Collaborating on .asp and .aspx webpages

Although this might not be the right forum for my question, I am diving into unfamiliar territory. Previously, I did some ASP.NET programming in VS.NET and would always debug using the menu to run and test the site. I noticed that it compiled during this ...

When I set margin-top to auto to move the last item in the list to the bottom, the item ends up being clipped

I have a sidebar with 100% height that includes a div and a ul. The div will display an image at the top of the sidebar, while the ul will contain all the sidebar menu items. It is crucial that the div and ul remain separate and not combined. The challeng ...

The responsiveness of CSS isn't functioning as expected

Struggling to achieve responsiveness on my page, facing issues with a white border at the top and image fitting problems. Any insights on what might be causing this? CSS: .cb-slideshow, .cb-slideshow:after { position: fixed; width: 100%; hei ...

Align the text in the center of the button vertically

Struggling to vertically center text on a button? I understand the frustration! I've been working on this issue for a whole day with no success. My setup involves NEXT.js and TailwindCSS. <main> <div class='flex justify-center ite ...

No data is retrieved from the ASP.NET WCF Service

I am experiencing difficulties with my WCF Service. I am trying to have my method return a list formatted in JSON. However, when I call the method, the response is empty. Even after setting the method's BodyStyle to Wrapped. If I return null, the ou ...

[ASP.NET/Credentials] Accessing Web Service

I have set up a Dynamics NAV 2016 Codeunit Web Service (SOAP Stream) that I want to integrate into an ASP.NET 4 web application. To validate user credentials, I need to utilize Windows Credentials. Below is a concise example of the code. using System; us ...

Tips to stop scrolling when clicking on a link in a Vue.js carousel

How can I prevent the page from scrolling when clicking on a link in a Vue.js carousel? I've created a carousel card to mimic the ones found on Netflix's main page. It works fine on a single component but when I add multiple carousel components ...

Glimpse triggering 500 error when loading images and CSS files

While setting up Glimpse on a .NET 4.6 project, I encountered an issue when installing the Asp.Net package from NuGet. All CSS and images started throwing a 500 error. To troubleshoot, I installed packages one by one until the error occurred with the speci ...

Tips for concealing a checkbox within the JS Tree Library

Is there a way to hide certain checkboxes generated by the JSTree library? Here is an example of the HTML structure: <div id="tree"> <ul> <li id="folder_1">Folder 1 <ul> <li id="child_1"& ...

Clickable button in a list of data

I'm facing an issue with accessing a LinkButton within the header template of a DataList in my code behind. I usually write the code like this: ((LinkButton)(DataList1.FindControl("LinkButton1"))).Enabled = false; However, I'm getting ...

Struggling to include a second-tier nested table with no luck

I've been attempting to figure out how to insert another nested table within the firstLevelGrid, but I'm not having much luck. Any guidance would be greatly appreciated. I seem to be encountering difficulties in managing the OnRowDataBound when c ...

When redirecting, .net does not empty listboxes

On a page I have several asp.Net listboxes. Once my code has gathered all the information and created a sql string, I redirect to a new page to display the search results. To keep the page neat in case the user returns to perform another search, I want to ...

Creating a Facebook-style comment box in ASP.NET using a repeater widget

My current setup includes a repeater with two columns: one containing a label and the other a textbox. However, I am facing an issue. Upon entering data into the textbox, it should display as a label, and another textbox in the same row should appear. I ...

How to detect the Back Button or Forward Button events in a single-page application

Currently, I am developing a single-page application that utilizes ASP.NET MVC, Backbone.js, and JQuery. My task involves capturing the browser's back and forward button events for breadcrumb implementation. I previously attempted to use the hashchan ...

Having trouble with clicking on ASP .Net LinkButton in WebDriver?

Currently, I am using WebDriver (2.35.0.0) with MStest and encountering an issue with the element.Click() method. While I am able to click on normal hyperlinks and asp:buttons without any problems, the Click() method fails to work in this scenario - Firefo ...

I am experiencing difficulties with my bootstrap module not loading

Could you please investigate why my module isn't loading? The module is supposed to load under the specified conditions in the third last column, but when I test the code, it doesn't work. Can you assist me in identifying what might be causing th ...

Utilizing margins in CSS for various div elements

Update: I have included Javascript and Masonry tags in my project. Despite having modules of the same size, I am exploring how masonry can assist me. However, I find it a bit puzzling at the moment as I am not aiming to align elements of different sizes. I ...

What is the method for writing to an HTML file with the use of expressjs?

Alright, I have an interesting idea here. I am looking for a way to allow users to push a button and have a new p element permanently added to the HTML file. This means that even after reloading the page, everyone should be able to see this new element. An ...