When the window is resized, Div escapes from view

My issue is that whenever I resize the browser, the div moves out of the window. I am using the jQuery scroll to plugin for navigating through divs. Oddly enough, when I resize the #home div, everything seems to work fine. However, when I resize other divs, they end up moving out of the window.

Could someone please help me out with this problem? You can access the website through this link.

Below is the code that I have used:

$(document).ready(function()
{
$("#bg-home").backstretch("images/Bg-home3.jpg");
var images = ['1.jpg', '2.jpg','3.jpg'];
$("#container").backstretch('images/' + images[Math.floor(Math.random() * images.length)]);
    $( "#draggable" ).draggable({
      drag: function() {
      $(".scrolldown span").css("color","lightgreen").html("Drop");
      },
      stop: function() {
        $(".scrolldown span").css("color","white").html("Drag");
      },axis: "x",containment:"#menu",scroll: false//,grid: [ 159,0 ]
    });
$(".content,.content1").droppable({drop: function() {
        var $url = $(this);
        document.title = $url.attr('alt');
        $('html, body').scrollTo($url.attr('id'),500,"easeInOutExpo");
        //event.preventDefault();
      }});
        $("#welcome").effect("slide",3000);
        $("#welcome").click(function()
        {
            $("#welcome").animate({left: "-1000px"},"easeInOutBounce");
            $(".about_w").animate({left: "100px"},"easeInOutBounce");
            $(".about_w").delay(4000).animate({left: "-800px"});
            $("#welcome").delay(4500).animate({left: "100px"});

        });
$('#menu a').bind('click',function(event){
        var $url = $(this);
        document.title = $url.attr('alt');
        $('html, body').scrollTo($url.attr('href'),500,"easeInOutExpo");
        event.preventDefault();
    });
$("#about .text p").vertiscroll({ width:6, color:'#f07','cover': 200,'areacursor': 'pointer' });
$('.side_container').slimScroll({
    height:"88%",
    color: '#fff',
    start: $('.side_container'),
    alwaysVisible: false
});
$('#container_wrap_metro').slimScroll({
    height:"400px",
    color: '#fff',
    railVisible: false,
    alwaysVisible: false
});
$(".menu nav").click(function(){
    $url = $(this);
  $(".text p").load($url.attr('id'));
});
function loading_show()
{
$('#loading').html("<p style='color:white;'>Loading</p><br><img src='images/loading.gif'/>").fadeIn('fast');
}

function loading_hide()
{
$('#loading').fadeOut();
} 
//Status
function loadData(page)
{
loading_show();
$("#container_wrap_metro").html("");
$.ajax({
      url: "load_data.php",
      type: "post",
      data: "page="+page,
      success: function(data){
            loading_hide();
           $("#container_wrap_metro").html(data);
      },
      error:function(){
          alert("failure");
          $("#container_wrap_metro").html('Unable to process request!');
      }  
    }); 
}
function loads(page)
{
$.ajax({
      url: "load_10.php",
      type: "post",
      data: "page="+page,
      success: function(data){
           $(".side_container").html(data);
      },
      error:function(){
          alert("failure");
          $(".side_container").html('Unable to process request!');
      }  
    }); 
}
loads(1);
//Search
$("#result").keyup(function(){
    $(".side_container").html('<center><i>Fetching...</i></center>')
    var q = $(this).val();
    $.get("results.php?q="+q, function(data){
    if(q){
        $(".side_container").html(data);
    } 
    else {
        loads(1);
    }
});
});
});

Answer №1

Consider modifying the lines below:

$("#greeting").animate({left: "-800px"},"easeInOutBounce");
$(".info_section").animate({left: "50px"},"easeInOutBounce");
$(".info_section").delay(3000).animate({left: "-600px"});
$("#greeting").delay(3500).animate({left: "50px"});

Also, adjust:

height:"450px",

It is important to note that using em or % for sizing in responsive web design is recommended. You can experiment with different values such as 100% or 45em until you achieve the desired outcome.

Answer №2

To achieve responsiveness, it is crucial to implement designs with percentage-based widths. Avoid using fixed pixel values like "left:..px" in your script as it can cause issues. Consider either adjusting your elements to be responsive or replacing them with responsive alternatives.

Check out this LINK

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

Utilizing various triggers to activate a single function in jQuery

Is there a more efficient way to execute a function when any of the multiple items on the page is clicked? The current function works but I'm looking for a better way using || or something similar. This is my current implementation: Init: function ( ...

What could be causing the issue preventing me from updating my SQL database through AJAX?

$(document).ready(function(){ $('.button').click(function(){ var clickBtnValue = $(this).val(); var ajaxurl = 'functions/delivered.php', data = {'action': clickBtnValue}; $.post(ajaxurl, da ...

Getting the value of an option from a select box in PHP with MySQL integration

I have developed a function specifically for a select box that is dynamically added to a jQuery table. However, I am encountering an issue where only the first value is being displayed in all rows. Can someone please guide me on how to fix this error? < ...

Sending a parameter between files in a React application: a step-by-step guide

I am currently working on a Pokedex website where I have Pokemon cards displaying data from a JSON file. When a user clicks on a card, a modal view appears with more detailed information about that specific card. I need help in ensuring that only the deta ...

Count the number of times an iteration occurs in AngularJS/JavaScript

I need assistance with my code snippet below, as I am trying to determine the count of all instances where $scope.rm is equal to "failed" or when $scope.percentage is less than 50. angular.forEach(result1, function (value, key) { $scope.percentage ...

Retrieving information from a database with AJAX in CodeIgniter

After clicking on a button in this code, the data is supposed to be fetched from a database and dynamically displayed within the appropriate div using jquery and ajax. However, I am not seeing any output. See below for the code snippet: Controller defi ...

Refresh the HTML content within a specified div element

In my index.html, there is a graph (created using d3.js) along with some code that displays a stepper with a number of steps equal to the child nodes of the clicked node: <div ng-include="ctrl.numlab==2 && 'views/stepper-two-labs.htm ...

Does Vuejs have a counterpart to LINQ?

As a newcomer to javascript, I am wondering if Vue has an equivalent to LinQ. My objective is to perform the following operation: this.selection = this.clientsComplete.Where( c => c.id == eventArgs.sender.id); This action would be on a collect ...

What is the best way to find the average time in Typescript?

I am dealing with an object that contains the following properties: numberOfReturns: number = 0; returns_explanations: string [] = []; departure_time: string = ''; arrival_time: string = ''; The departure_time property hold ...

Issues encountered while modifying Vue data

In my Vue JS 2 code, I have structured my data as follows: data : { newBus: { name: '', hours: { sunday: '', } } } When setting the data usi ...

Is there a way to directly send an API Request from a Controller in Laravel 5.2?

I'm currently in the process of working on a project that involves API integration across multiple websites. While progressing, I realized that I've been relying heavily on AJAX requests using JQuery in my code (which can be viewed in the page s ...

The process of creating a functional search bar in Django

I created a search bar, but I am facing an issue where no titles appear until I start typing. Once I type in one title, all the titles suddenly appear. How can I fix this problem? index.html def index(request): query = request.GET.get('srh' ...

Tips for referencing page URLs in a jQuery Ajax request within a Master Page in ASP.NET

I have successfully implemented a webmethod call from the Master Page in my asp.net project. In my solution explorer, the "Master Page" and "MyService.asmx" files are located in the root folder, while the content pages are inside an "Admin" folder. When I ...

What is the best way to customize the style of a react.js component upon its creation?

Is there a way to set the style of a react.js component during its creation? Here is a snippet of my code (which I inherited and simplified for clarity) I want to be able to use my LogComponent to display different pages of a Log. However, in certain ins ...

Encountering a parse error when making an AJAX call using structural functions

I'm in the process of developing an API and here is my PHP function. function retrieve_schools($cn){ $schools_query = "SELECT * FROM schools"; $school_result = mysqli_query($cn, $schools_query); $response_array['form_data'][&apo ...

What is the proper way to invoke a function that is part of a child component as a property in a React application?

In my app.js file, I have included a unique component called "SigningComponent" with the following code: onSign = () => { this.setState({ route: "home" }); }; registerFunction = () => { this.setState({ route: "registration" }); }; render() { ...

I am looking to display the results table on the same page after submitting a form to filter content. Can you provide guidance on how to achieve this?

Could someone provide guidance on how to approach the coding aspect of my current issue? I have a search form that includes a select form and a text box. Upon submission, a table is generated with results filtered from the form. Should I utilize a sessio ...

The floating property doesn't appear to function properly in Internet Explorer versions 6 through 8 when

I've noticed that my website in Dutch looks great on Firefox and Safari (both Mac and PC), as well as Chrome (Mac tested, PC untested), but for some reason it's not displaying correctly on IE 6-8 (which is unavailable on Mac). I suspect there may ...

Tips for altering the color of a specific row in JQuery by targeting its unique id

I've been struggling to accomplish a simple task using Jquery and CSS, but I seem to be stuck. My issue involves making an ajax request to update a PostgreSQL table and retrieve an id in return. This id corresponds to the id of a row in a previously ...

How can I stop my browser from recalling text field data?

Similar Question: Is there a W3C compliant method to disable autocomplete in an HTML form? How can I stop a browser from remembering the text field's content? The issue arises when the field has a value like 100, followed by a currency symbol suc ...