The resizable function in jQuery is not functioning as expected

Within my project, the initial page includes the following code snippet:

html

<div id="box">
    <div id="header"> <span id="title"></span> <span id="button">X</span> </div>
    <div id="text"> </div>
</div>

css

#box {
    border-style: solid;
    box-shadow: 2px 2px 2px black;
    max-width: 66%;
    max-height: 80%;
}

#button {
    background-color: #99CCFF;
    min-width: 32px;
    max-width: 5%;
    min-height: 32px;
    max-height: 100%;
    position:absolute;
    right:0px;
    text-align:center;
    padding-left:10px;
    padding-right:10px;
}

#header {
    background-color: #66B2FF; 
}

#title {
    text-decoration-color: #FFFFFF;
    font: 28px arial;
}

#text {
    background-color: #E0E0E0;
    text-decoration-color: #000000;
    font: 24px sans-serif;
    overflow: scroll;
}

I have made this element draggable and resizable using the corresponding jquery functions. While the Drag behavior works flawlessly, the Resize function does not.

The jQuery code to adjust this behavior is as follows:

$('document').ready(function(){
    $('#box').draggable({
        cointainment: "#container"
    });

    $('#box').resizable({
        cointainment: "#container"
    });

    $('#box').hide();

    $('#button').click(function(){
        $('#box').hide();
    });

    $('a').click(function(e){
        if($(this).attr('href') != 'logout.html') {
            e.preventDefault();
            $.get($(this).attr('href'), function(data){
                var $temp  = $('<div/>', {html:data});
                $('#title').text($temp.find('title').text());
                $('#text').html($temp.remove('head').html());
                $('#box').show();
            });
        }
    });
});

Is there any error in the above code that someone can spot?

ps.: Additionally, I have a question regarding the CSS display mentioned earlier. As you can see, I have defined both max-width and max-height; however, the max-height attribute does not seem to be functioning correctly. Can anyone identify what might be wrong with it?

Answer №1

Your code already has the resizable functionality, but you need to style the .ui-resizable-handle for it to be visible and usable. If you can't click and hold on the handle, resizing won't work.

For example, adding the following CSS:

.ui-resizable-handle {
    width: 20px;
    height: 20px;
    background: red;
}

will enable resizing.

Check out the DEMO to see it in action.

Explore more options of the resizable widget on this page.

You can also view demos of different resizable options 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

Change the width of specific <li> elements to create variation

My goal is to configure a ul element with varying widths using flex. Specifically, I want the first two items in the ul to be 60% width while the last two items should be 40%. However, my flex-basis property doesn't seem to be working as expected. ...

Select a Button to randomly choose another Button

I am currently developing a dynamic Bootstrap OnePage-Website using HTML, CSS, and JavaScript. The highlight of this website is the Team section where users can book appointments with one of three team members by clicking on a corresponding button beneat ...

Attempting to get the boxes in the final row to show up

Exploring new territories in web design, I'm currently working on achieving the layout shown below: Box Layout I've encountered an issue where the last row of 4 boxes in the middle section is not appearing as intended. Once this row is successfu ...

The scrollTop feature fails to function properly following an Axios response

I'm currently facing a challenge with creating a real-time chat feature using Laravel, Vue.js, Pusher, and Echo. The issue arises while implementing the following 3 methods: created() { this.fetchMessages(); this.group = $('#group') ...

The container holding the inner elements is slightly oversized by a couple of pixels

Check out this Plunker example. Hello everyone, I am currently working on fitting two inner divs (a title bar and a canvas) inside an outer div. These inner divs are generated dynamically and have specific fixed dimensions. Below is a sample code snippet ...

What are the specifications for the opacity, width, and height of the background image in Bootstrap's

My current project has specific requirements that I need assistance with: I need the background image of the jumbotron to fit the width of the page and have its height scaled proportionally. The opacity of the jumbotron's background image should be ...

Setting up Stylelint in a Next.js project: A step-by-step guide

I'm looking to incorporate Stylelint into my Next.js app. Can I modify the next.config.js file to include the stylelint-webpack-plugin, in order to receive style errors during compilation? // next.config.js module.exports = { reactStrictMode: true, ...

Elevate when the mouse hovers over the button

My current task involves increasing the bottom-padding of a span when the mouse hovers over a button. Here is the button code: <button class="btn btn-success btn-circle" id="myBtn" title="Go to top"> <span id="move" class="fa fa-chevron-up"&g ...

.comment {Visibility:hidden;} is only functioning on one specific page

What could be the reason behind this function only functioning on one page and not the others? The URL in question is . Specifically, the functionality is only active on the contact page while all other pages still display a comment section. ...

Place a user input field within a div element having the specified class

I am trying to insert an HTML input element into the following div: <div class="sss" style="padding-top:2px"> <center> <input value="test1" name="name1" type="submit" > <input value="test2" name="name2" type="submit"> </c ...

The CSS class in jQuery Mobile is not being properly displayed on the input field

I'm having trouble getting the .ui-input-text class to apply to the input field, despite using the jQuery Mobile class for text inputs. The border radius is not changing unless I manually add it in with CSS code. Here's my current setup: <!DO ...

After closing the modal, I am attempting to reset it, but unfortunately, it is not functioning as expected

I have a modal box with the following structure: <div class="modal-coupon-code"> <center class="show-code"><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#couponcode<?php echo $result->id; ?> ...

Whenever trying to access data from the database using DataTable row(), it consistently remains undefined and fails to retrieve any information

While working on my application, I attempted to display all the data in a DataTable from the database. Unfortunately, instead of achieving this, I encountered an error from the server. Upon receiving the error, the dataTable object was displayed as follows ...

CSS code that causes the animated photo banner to reset instead of continuously looping back to the first

I followed a tutorial and created this banner using HTML and CSS. However, I encountered an issue where instead of the banner continuing in loops, it keeps resetting. Since we haven't covered JavaScript yet in university, I'm looking for help to ...

Issues with hover styles and transitions not being correctly applied to newly appended elements in Firefox

Utilizing an SVG as an interactive floor plan, I have implemented a feature where hovering over different areas on the floor plan (<g> elements) causes them to expand and float above other areas. The element scaling is triggered by CSS, but I use jQu ...

Adjusting the form action dynamically based on session variable: A step-by-step guide

In the scenario where I have a form and the action needs to vary based on a session variable, how can I dynamically change the action so that when a specific link button is clicked by the client, the form can be submitted with the correct action? <fo ...

The <nav> and <section> elements are not appearing on the page

Website: CSS: Hello there! I am experiencing an issue where the nav and section elements are not displaying on my website. They seem to only show the height and background-color attributes. Interestingly, they appear correctly on my old Firefox version ( ...

How to Implement jQuery in a GridView?

I am facing an issue with implementing a jQuery autocomplete plugin on an edit piece inside a traditional ASP.NET GridView. The plugin seems to work fine outside of the GridView, so it's definitely functional. Below is the ASP.NET code snippet (inclu ...

Switching between nested lists with a button: A simple guide

I have successfully created a nested list with buttons added to each parent <li> element. Here is how the list is structured: $("#pr1").append("<button id='bnt-cat13' class='buttons-filter'>expnd1</button>"); $("#pr ...

Updating a function in jQuery UI after dynamically loading content through AJAX

I've been on a quest for days now, searching high and low for an answer to my dilemma. While I've managed to solve most of the issues that arose after adding AJAX calls to my code, there's one piece that still eludes me. Just to provide som ...