Overlapping Divs - HTML Elements Crossing Paths

My challenge is to position the Social Icons at the bottom of the screen and align the Image Gallery in the middle. However, the social Icons keep moving to the center of the screen and the Image gallery ends up overlapping them, making it difficult for me to keep it at the bottom.

Every time I make an addition to the page, it seems to impact the positioning of the social icons.

<!DOCTYPE html>
    <html lang="en">
        <head>
            <title>Images</title>
            <meta charset="utf-8"/>
            <meta name="viewport" content="width=device-width, inital-scale=1">

            <link rel="stylesheet" type="text/css" href="reset.css"/>
            <link rel="icon" type="image/png" href="images/ace.png"/>
            <link rel="stylesheet" type="text/css" href="style.css" media="all"/>
            <script type="text/javascript" src="js/jquery.js"></script>
            <script type="text/javascript" src="script.js"></script>

            <link href="example/imageStyle.css" rel="stylesheet" type="text/css" media="all" /> 
            <link href="example/jphotogrid.css" rel="stylesheet" type="text/css" media="screen" /> 
            <!--[if IE]>
                <link href="jphotogrid.ie.css" rel="stylesheet" type="text/css" media="screen" />
            <![endif]--> 
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
            <script src="example/jphotogrid.js"></script>
            <script src="example/jflickrfeed.js"></script>
            <script src="example/setup.js"></script>

        </head>

        <body>

            <div class="header">
            </div>                    
            <span class="menu-Trigger" align="center" >&#9776; Menu</span>
            <div class="nav-menu">
                <ul>
                    <li><a href="index.html">HOME</a></li>
                    <li><a href=#>VIDEOS</a></li>
                    <li class="current"><a href="Images.html">IMAGES</a></li>
                    <li><a href=#>EVENTS</a></li>
                    <li><a href=#>TESTIMONIALS</a></li>
                    <li><a href="Contact.html">ENQUIRIES</a></li>
                </ul>
            </div>

            <div class="main">
                <ul id="pg">
                    <li>
                        <img src="http://farm4.static.flickr.com/3647/3435384001_9ed9864bb4.jpg" alt="DSC_0660">
                        <p>DSC_0660</p>
                    </li>
                    ...
                    <!-- More images and descriptions -->
                    ...
                </ul>
            </div>

            <section>
                <div id="middle">
                </div>
            </section>

            <div class="sI">
                <div class="icons">
                    <a class="socialIcons" href="http://www.youtube.com" title="Subscribe on YouTube" alt="Arshdeep on YouTube"><img src="images/social/youtube.png"/></a>
                    <a class="socialIcons" href="http://www.instagram.com/ArshSoni" title="Subscribe!" alt="Arshdeep Soni"><img src="images/social/instagram.png" /></a>
                    <a class="socialIcons" href="http://www.facebook.com/MagicArsh" title="Arshdeep Soni on Facebook" alt="Facebook"><img src="images/social/fb.png" /></a>
                    <a class="socialIcons" href="http://twitter.com/ArshSoni" title="Follow Arshdeep on Twitter" alt="Twitter"><img src="images/social/twitter.png" /></a>
                </div>
            </div>

        </body>
    </html>

CSS:

<style type="text/css>
                    body {
                        background-color: black;
                    }

                    .icons {
                        text-align: center;
                        position:absolute;
                        bottom:0px;
                        left:0;
                        width: 100%;
                        border:2px solid red;
                    }    
                    .main {
                        width: 700px; 
                        margin: 0 auto; 
                        text-align: left; 
                    }

                    #middle {
                        height:100px;
                    }


                </style>

JSFIDDLE: https://jsfiddle.net/dzx9v25b/

Answer №1

you should definitely give this a shot.

.uniqueClass{
 position: absolute;
}
.icons{
text-align:center;
}

Answer №2

By eliminating the "position:absolute;" property in the .icons class, you can resolve the issue you are experiencing. This adjustment will typically set your position element to static by default. For more information on various CSS positioning techniques, check out this informative article.

Answer №3

To make the necessary adjustments in your CSS, simply switch from position:absolute to position:relative for the .icons class.

JSFiddle : Live Example

Modified CSS:

body
{
background-color: black;
margin: 0; /* Updated */
}
.main {
width: 700px; 
height: auto; /* Updated */
overflow: auto; /* Updated */
margin: 0 auto; 
text-align: left; 
}

#pg {
position: relative;
display: block; /* Updated */
height: auto; /* Changed to 585px */
background: #000;
margin-bottom: 50px;
margin-top: 50px;
}

Answer №4

To position icons at the bottom of the page

Simply remove the line height: 585px; from your CSS selector #pg and replace it with overflow:auto;

It's important to use overflow:auto; for containers containing floated elements to maintain their ability to expand according to content, as the float property takes them out of the normal document flow.

By setting a specific height for your #pg container, you were tricking the rest of the document into prematurely ending, leading to overlap issues.

You can view a working example here

if you want the icons to always stay visible:


To Keep Icons at Bottom of Viewport

I've made adjustments in your code which you can see in this updated Fiddle link.

Your icons require position: fixed; to remain at the bottom of the viewport. Additionally, a higher z-index value is needed to keep them above the images.

I hope this information proves helpful!

Answer №5

Check out this suggestion, it could be beneficial for you

.icons {
    text-align: center;
    position:absolute;
    bottom:0px;
    left:0;
    width: 100%;
    border:2px solid red;
}

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

Creating enduring designs in Next.js

I've been diving into this amazing article and I'm puzzling over the implementation of persistence in Option 4. It seems like you would need to redefine the .getLayout method for each page. I'm uncertain about how nesting logic is handled fo ...

Is it possible to automatically extract HTML code from a webpage using a function, without having to do it manually?

Is there a way to fetch the HTML code of a website after running a particular function? Here's the scenario I'm dealing with: I need to extract the link of a source embedded in an iFrame element that only becomes visible when I execute a specif ...

Using the setTimeout function in Vue.js to trigger the play of an audio file at a specified

I have set up a Vue-audio player in my Vue.js application using the AudioPlayer component. This is my code: <template> <vue-audio id = "myAudio" :file= "file1"/> </template> <script> import VueAudio from 'vue-audio'; ...

Invoke an RxJs observable to handle errors and retry the process

I have an observable called submit$ that submits a form. If this observable encounters an error with status code 403, it means the user is not authorized and needs to log in first. Is there a way to automatically trigger another observable when a specific ...

What is the best method to position a modal in the exact center of the screen?

Is there a way to position the modal at the center of the screen? I have tried implementing this HTML and JavaScript code. Interestingly, it works fine in Chrome console but fails when I try to refresh the page. $('.modal').css('top', ...

Obtaining Asynchronous JavaScript responses with Selenium Webdriver

We recently integrated an asynchronous JavaScript call into our website. I am currently working on configuring Selenium Webdriver to pause and wait for a response from this particular call. The event listener code snippet is as follows: $(document).on("a ...

Seems like ngAfterViewInit isn't functioning properly, could it be an error on my end

After implementing my ngAfterViewInit function, I noticed that it is not behaving as expected. I have a hunch that something important may be missing in my code. ngOnInit() { this.dataService.getUsers().subscribe((users) => {this.users = users) ; ...

Unable to configure slick carousel to a 12-column grid in Bootstrap

When attempting to set my carousel to col-xs-12, the columns do not align correctly within the slick carousel in Bootstrap. If I change it to col-xs-6, it works fine but then two grids appear in one row. I require more space for my carousel. Could I be ov ...

Tips for incorporating the "build" directory into the Travis-CI build process and deployment of an npm module

Currently, I am working with a Typescript module that has a directory ./src And I also have travis-ci set up for the project. language: node_js node_js: - 5.1.0 install: - npm install - npm install -g mocha - npm install -g gulp - npm install -g tsd - ...

IE11 not running Angular code inline as expected

Currently in the process of developing an AngularJS application, I came across a strange issue that I have never encountered before. It may be a simple fix, but I am unsure of the exact terminology to search for the right solution, so I apologize in advanc ...

Executing a command upon the pressing of the enter key within a text input field

Here is my input field: <input type="text" id="word" /> I am looking for a JavaScript function that will be triggered when the user hits enter in this text box. I searched for an answer but couldn't find one that fits my spe ...

Guiding motion of a parental container using a button

This seems like a fairly straightforward task, but I'm getting a bit frustrated with it. Is there a way to move an entire div by simply holding down the mouse button on a particular button? let container = document.getElementById('abo ...

Ensure that the table is padded while keeping the cells collapsed

I am currently working on creating a table with borders between each row. However, I am facing an issue where the row borders are touching the outer border of the table. Despite my efforts, I have been unable to find a solution to this problem. I feel like ...

Is it possible to utilize a JavaScript variable in this particular scenario and if so, what is the

let myVariable = <?php echo json_encode($a[i want to insert the JS variable here]); ?>; Your prompt response would be highly valued. Many thanks in advance. ...

Is there a way to retrieve the same post from one controller and access it in another?

Hello, I am currently exploring the world of Full Stack web development and have stumbled upon a challenge. My tech stack includes mongodb, mongoose, node, and express. Within my project, I have implemented two controllers - one for user signup and anothe ...

How can I make a bootstrap container maximize the available viewport space?

I've come across several similar posts, but none seem to address my particular dilemma. My challenge lies in presenting a table at the end of a bootstrap grid: <div class="container-fluid"> <!-- Various rows with different size ...

"Troubleshooting: Why is the JavaScript canvas.toDataURL method returning an

While I know this question has been asked multiple times before, I still haven't been able to find a solution. My goal is to take an image, rotate it, and place it in an HTML canvas. To achieve this, I am utilizing another canvas where I rotate the i ...

Display the accurate prompt in the event of 2 `catch` statements

elementX.isPresent() .then(() => { elementX.all(by.cssContainingText('option', text)).click() .catch(error => { throw {message: "Unable to select text in dropdown box"} ...

Is organizing a table into separate sections helpful?

I'm currently working on a personal project using Material UI, but I have a more general query regarding table implementation. I have designed a layout in Figma that I like, but I am struggling to translate it into code. https://i.sstatic.net/NoWEB.p ...

Activate a function when the VueJS countdown timer hits zero

I've successfully created a countdown timer in the template that decrements a number perfectly. Now, I'm facing the challenge of triggering a function declared within the methods section once the countdown reaches 0. Despite attempting to check i ...