struggling to align the div elements

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Cougar Inn Directions</title>

    <link rel="stylesheet" type="text/css" href="case.css" />
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="case.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
</head>
<body>
    <div id="header">
        <h1>Welcome to the Cougar Hotel</h1>
    </div>
    <div id="navcon">
        <div id="nav">
            <ul>
                <li style="border-Left: 1px solid #e9e9e9"><a href="cougarhome.html">Home</a></li>
                <li><a href="#">About Cougar Inn </a>
                    <ul>
                        <li><a href="#">Accommodations</a></li>
                        <li><a href="#">Services/Amenities</a></li>
                        <li><a href="#">Meeting/Events</a></li>
                    </ul>
                </li>
                <li><a href="cougarreservation.html">Reservations</a></li>
                <li><a href="cougardirections.html">Directions</a></li>
                <li><a href="contactus.php">Contact Us</a>
                    <ul>
                        <li><a href="contactus.php#phone">Phone</a></li>
                        <li><a href="contactus.php#email">Email</a></li>
                        <li><a href="contactus.php#feedback">Feedback</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <!-- end navcon -->
    </div>
    <!-- end nav -->
    <div id="pagewrapper">
        <div class="pagecon">
            <h2>This is class pagecon</h2>
            <p>
                <div id="slideshow">
                    <div>
                        <img src="hotel 1 s.jpg" alt="HomePic1">
                    </div>
                    <div>
                        <img src="hotel 4 s.jpg">
                    </div>
                    <div>
                        <img src="hotel 6 s.jpg">
                    </div>
                </div>
                <div class="bodycon">
                    <h1>Directions to</h1>
                    <iframe width="425" height="350"
                        src="https://maps.google.com/maps;output=embed"></iframe>
                </div>
                <!--end bodycon -->

                <table border='1' class="tablecon">
                    <tbody>
                        <tr>
                            <td>
                                <p>
                                    *From Hwy 37 get off at the Stadium exit and head<br>
                                    east down Broadway to N College Ave.  Turn right on College<br>
                                    onto Bangle Street.  We are right next to Columbia College.
                                </p>
                            </td>
                            <tr>
                                <td>
                                    <p>
                                        *From I-141 get off at the Hues St exit. Head south<br>
                                        on Hues till you get to Bangle St.  Turn right on Bangle<br>
                                        and you will see the Bangle Inn next to the College.<p>
                                </td>
                            </tr>
                    </tbody>
                </table>
        </div>
        <!--end class pagecont -->
    </div>
    <!-- end pagewrapper -->
</body>
</html>

The following CSS styles have been applied:

 * {
    margin: 0px;
    padding: 0px;
}

#header {
    background-image: url(./headimg.jpg);
    height: 60px;
    background-repeat: repeat;
}

#navcon {
    background-image: url(./wood.jpg);
    width: 100%;
    border-bottom-style: solid;
    border-bottom-width: thick;
    border-bottom-color: #083272;
}

#nav {
    width: 450px;
    height: 30px;
    position: relative;
    color: #080808;
    font-family: arial, sans-serif;
    margin: 0px auto;
    font-size: .9em;
}

    #nav ul {
        list-style-type: none;
    }

        #nav ul li {
            float: left;
            position: relative;
        }

            #nav ul li a {
                border-right: 1px solid #e9e9e9;
                padding: 5px;
                display: block;
                text-align: center;
                color: #080808;
                text-decoration: none;
            }

                #nav ul li a:hover {
                    background: #144678;
                    color: #fff;
                }

            #nav ul li ul {
                display: none;
            }

            #nav ul li:hover ul {
                display: block;
                position: absolute;
                z-index: 1;
            }

                #nav ul li:hover ul li a {
                    display: block;
                    background: #144678;
                    color: #fff;
                    width: 120px;
                    text-align: center;
                    border-bottom: 1px solid #f2f2f2;
                    border-right: none;
                }

                    #nav ul li:hover ul li a:hover {
                        background: #4879A5;
                        color: #fff;
                    }

body {

background: #B5C4D9;
}

#pagecont {
width: 980px;
margin: 0 auto;
position: relative;

} 

.pagecon {

    background-image: url(./mainbackimg.jpg);
    margin: 15px;
    padding: 15px;
    border-style: solid;
    position: relative;

    min-height: 100%;
    float: left;
}

.bodycon {

    background: #5F86C0;
    margin: 20px;
    padding: 15px;
    border-style: solid;
    position: relative;
    height: auto;
    min-height: 100%;
    float: left;
}


.tablecon {
    margin: 20px;
    padding: 15px;
    border-style: solid;
    position: relative;
    height: auto;
    min-height: 100%;
    float: left;
}

#slideshow {
    margin: 10px auto;
    position: relative;
    width: 350px;
    height: 247px;
    padding: 10px;
    float: left;
    border-style: solid;
}

    #slideshow > div {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

I'm trying to align the boxes so that the pictures are on the left. The "directions to" box should be next to the pictures box and aligned with it vertically. The table should be placed directly below the pictures box without too much space in between. I've been tweaking this layout for some time now and would appreciate any assistance.

Answer №1

After making some adjustments to your code, I restructured it by creating a wrapper for the #slideshow element and placing the table with the slideshow inside that wrapper to align them in a column format:

<div class="left-wrapper">
    <div id="slideshow">
        <div>
            <img src="hotel 1 s.jpg" alt="HomePic1">
        </div>
        <div>
            <img src="hotel 4 s.jpg">
        </div>
        <div>
            <img src="hotel 6 s.jpg">
        </div>
    </div>
    <table border='1' class="tablecon">
        <tbody>
            <tr>
                <td>
                    <p>
                        *From Hwy 37 get off at the Stadium exit and head<br>
                        east down Broadway to N College Ave. Turn right on College<br>
                        onto Bangle Street. We are right next to Columbia College.
                    </p>
                </td>
            </tr>
            <tr>
                <td>
                    <p>
                        *From I-141 get off at the Hues St exit. Head south<br>
                        on Hues till you get to Bangle St. Turn right on Bangle<br>
                        and you will see the Bangle Inn next to the College.<p>
                </td>
            </tr>
        </tbody>
    </table>
</div>

The CSS class for the wrapper is:

.left-wrapper {
    display: inline-block;   
}

The updated CSS for #slideshow is:

#slideshow {
    margin: 10px auto;
    position: relative;
    width: 350px;
    height: 247px;
    padding: 10px;
    border-style: solid;
}

The new CSS for .bodycon is:

.bodycon {
    background: #5F86C0;
    margin: 10px 20px;
    padding: 15px;
    border-style: solid;
    position: relative;
    height: auto;
    min-height: 100%;
    display: inline-block;
    vertical-align: top;
}

For more details, visit the updated fiddle

Answer №2

To fix the issue of your div.bodycon being positioned lower than your div#slideshow, you need to make sure their top-margin settings are set to the same number. Adjust both margins to be equal for proper alignment.

Visit this link for more information.

.bodycon {
  margin: 10px;
  /* Additional styles here */
}

#slideshow {
  margin: 10px;
  /* Additional styles here */
}

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

Animating images on scroll using Bootstrap's utilities

Is it possible to use bootstrap for creating a responsive animation of a bicycle moving from start to end as the user scrolls down the page? Additionally, how can I incorporate a responsive dotted line using bootstrap as well? Are there any codepen exampl ...

When the CSS style sheet is not embedded within the HTML document, it fails

I'm facing an issue while trying to apply currency formatting to an HTML table in order to have it display correctly when opened in Excel. Initially, I tried doing this inline and it worked fine, like so: <td style="mso-number-format:$\##&bso ...

Compiling Nextjs with Tailwind typically takes anywhere from 8 to 16 seconds

My first time using tailwind has resulted in slow compilation times when used with nextjs in development mode. The slowdown can be confirmed by simply removing the following code: @tailwind base; @tailwind components; @tailwind utilities; This significan ...

What is the best way to ensure the footer is always positioned at the bottom of each page

Hey there, I'm having an issue with printing a large table on my HTML page. I want the footer to appear at the very bottom of every printed page, but so far I haven't found a perfect solution. I came across using tfoot, which prints the footer at ...

What could be causing the input submit in my form to be unresponsive when clicked?

I'm stumped on what's causing the issue. My sign-up form seems to be malfunctioning - when I click the "Complete Registration" button, nothing happens! The form doesn't even submit. Here is the HTML structure: <!DOCTYPE html> <html ...

Utilizing JavaScript to send emails from HTML without relying on the default Outlook client

Is it possible to send an email using JavaScript without relying on Outlook or the mailto object? I'm looking for a direct method that can submit form data directly to an email address. Does anyone know of a way to achieve this with JavaScript? ...

Selenium is having trouble finding the link within the table

While writing a Selenium script, I encountered an issue with locating a link in a table on an HTML page. Using "css=table tr:nth-child(2) td:nth-child(3) a" did not work and resulted in a "[error] locator not found" message in Selenium IDE. However, when ...

Updating View in Angular 2 ngClass Issue

I'm encountering some challenges with updating my view using ngClass despite the back end updating correctly. Below is my controller: @Component({ selector: 'show-hide-table', template: ' <table> <thead> ...

Ways to serve HTML without relying on code generated by JQuery

I am currently utilizing the html() function in JQuery to extract the HTML content of a specific div on my web page. Nevertheless, the output includes all the code generated by JQuery as well: <ul><li id="fact_1" class="jstree-open"><ins cl ...

Inserting cards into an HTML document using JavaScript

I have a situation where I need to display 3 cards in a row instead of stacking them vertically. How can I achieve this? arr = [{ "Name": "Peter", "Job": "Programmer" }, { "Name": "John", "Job": "Programmer" }, { "Name": "Kev ...

Troubleshooting textarea resize events in Angular 6

In the development of my Angular 6 application, I have encountered an issue with a textarea element. When an error occurs, an asterisk should be displayed next to the textarea in the top-right corner. However, there is a gap between the textarea and the as ...

What is the best way to incorporate this design utilizing the Bootstrap Grid system?

I am trying to create a grid structure using the code below: <div class="col-lg-8"> <div class="col-lg-6"> <div class="panel panel-primary"> <!-- Default panel contents --> <div class="panel- ...

JavaScript and HTML: Importing local JSON and considering module accessibility

My journey with javascript / html is just beginning, and I find myself struggling to grasp the import / module functionality. My current challenge involves loading a json file into javascript. After some research, I came across using import as the best wa ...

How can you align a list next to a set of images using HTML and CSS?

When working with these images in my code, I need to create a list alongside them: <div class="asideContent"> <ul> <li> <p> </p> </li> <li> <p></p> </li> ...

Issues with buttons and grid layout in HTML and CSS

I am facing issues with setting up the buttons. I'm not sure whether a grid system is needed for this task or not. I want the design to resemble the following example: I haven't written any code yet as I am unsure about where and how to begin. ...

Opacity is causing issues with hover effects in CSS

I'm facing an unusual CSS challenge. Check out this simple code snippet below that showcases the issue: <html> <head> <style> .hover { float: right; } .hover:hover { background-color: blue; ...

Utilize PHP's foreach loop to showcase information within multiple HTML div containers

I am presented with the following data and would like to showcase it in separate containers using HTML. Name Price Difference Signal CA.PA 15.85 3.5609257364073 MACD AZN.ST 896 3.4881049471963 MACD AMGN 258.57 1.6391533819031 SMA 50/ ...

Tips for clearing state when simply refreshing a DataTable on the page

When it comes to a datatable on a page, I am facing a unique challenge. I want the datatable to be refreshed with a clear state (no column order, etc.), but if the page is accessed by pressing the back button, it should retain its state. I have experiment ...

Is it possible to achieve avoidance of width calculation using only CSS?

Check out this link for more information. For a working version, visit: this site. The issue here is that Angular is calculating the width of the slider when the directive is processed, but since the item is not visible, it has no width. The labels on th ...

When data is sent to a function through ejs, crucial information becomes accessible on the html page sources

I have encountered an issue where sending data to a function through ejs makes it easily visible in the page source. Could this pose a security risk? Example of code: <a onclick="editDetail('<%=JSON.stringify(data[i])%>')">Edit</ ...