DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

Moving div around the page, it gets deformed on screen edge

377 Views Asked by AndreaBogazzi At 20 August 2013 at 16:44 2025-12-20T23:53:50.072000

I have some popups whit this structure:

<div id="pop_cont" class="popup_cont" >
    <div id="pop" class="popup" >
        <div class="xclose" ><img src="images/divclose.png" onclick="closediv('pop_cont');" title="chiudimi" /></div>
        <div id="pop_title" class="popup_title" >TITLE</div>
        <div id="pop_int" >SOME CONTENT</div>
    </div>
</div>

with this css:

#alert_cont, .alert_cont, .popup_cont {
    z-index:600;
    position:fixed;
    top:0px;
    left:0px;
    width:100%;
    height:100%;
    background-color:rgba(0,0,0,0.5);
    display: none;
}

#alert, .alert, .popup{
    position: absolute;
    background-color: white;
    border: 1px solid black;
    border-collapse: collapse;
}

#alert_int, .alert_int, .popup_int{
    padding:10px;
}

.xclose {
    right: 1px;
    top: 1px;
    float: right;
    cursor:pointer;
    border:0px; 
}

#alert_title, .alert_title, .popup_title{
    background-color:#ffd600;
    border:1px solid #ffe666;
    color: #000000;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    text-align:center;
    cursor: move;
}

I later move the popup i get , grabbing the "class='popup_title'" divs and moving around the parent element. Using this kind of script:

var oDrag = null
var x,y,dx,dy

function mdown(e) {
    if (!e) var e = window.event;
    oDrag = (e.target) ? e.target : e.srcElement
    if (oDrag.className=='popup_title'){
        oDrag=oDrag.parentElement;
        x = e.clientX;
        y = e.clientY;
        dx = x - parseInt(oDrag.style.left);
        dy = y - parseInt(oDrag.style.top);
        document.onmousemove=mdrag_on;
        document.onmouseup=mdrag_off;
    } else {
        oDrag = null;
    }
}

function mdrag_on(e) {
    if (!e) var e = window.event;
    oDrag.style.left = parseInt(e.clientX - dx)+'px';
    oDrag.style.top =parseInt(e.clientY - dy)+'px';
    return false
}

function mdrag_off(e) {
    document.onmousemove=null;
}

Very simple but it works. The problem is that when i get near the edge of the screen, right edge, the div get i'm moving get compressed instead of going offscreen. It get compressed till is possible , wrapping text , when not possible anymore it goes offscreen. When i go back it goes to is standard dimension as soon as possible. There is any method to avoid this? like setting some css of the div i'm moving?

html off-screen
Original Q&A
1

There are 1 best solutions below

0
AndreaBogazzi AndreaBogazzi On 21 August 2013 at 12:23

Ok i solved. Or really i didn't solve but i found design error and sort of solution. I have a container that basically is the big shadow that cover everything when the popup comes out. The popup is child of this shadow, so when i go edge of the screen, really i go edge of the shadow and the web browser of course try to make the popup stay inside it. So i gave

width:300%

to my "shadow" container and now it looks fine. ( strange on the left and bottom side it was not happening... )

So now real solution would be to make the shadow not parent to popup, but this would require to have to style.display='block' each time i need to show a popup ( big deal? ) or keep this width:300% Someone as some good suggestion to give me?

Related Questions in HTML

  • Delay in loading Html Page(WebView) from assets folder in real android device
  • Why does a function show up as not defined
  • CSS Class is not applying to element (border width,color,and style attributes)
  • How to sort these using Javascript or Jquery Most effectively
  • how to fill out the table with next values in array with one button
  • Automatically closing tags in form input?
  • Positioning child at bottom of parent with scroll
  • Remove added set of rows
  • Website zoomed out on Android default browser
  • Twitter Bootstrap horizontal form elements on a line
  • http://sigmajs.org/ les mis tutorial - why are my canvases 0 height?
  • My navbar is not expanding after collapse
  • when a checkbox is checked how to display a different hidden element using javascript
  • Gaps Vertically Using Dividers
  • Svg containers not positioning properly

Related Questions in OFF-SCREEN

  • How to create a vertical off-canvas drop down menu in Foundation?
  • OpenGL selective offscreen render to one of 2 textures in one fragment shader
  • Remote off-screen rendering (Linux / no GUI)
  • Qt: render QML window to buffer
  • android viewPager2 turns on offscreenPageLimit
  • Android Canvas Off Screen Drawing Performance
  • Create "invisible" graphics
  • Painting TRichEdit to a canvas
  • Off screen rendering mode in iOS
  • Onscreen Rendering as well as Offscreen Rendering of electron window
  • android animating buttons from offscreen bottom to onscreen are blank
  • Moving div around the page, it gets deformed on screen edge
  • WPF - simulate mouse events on off-screen rendered Grid
  • glReadPixels read "out of frames" area
  • Drawing offscreen with Quartz2D and using the result as an OpenGL ES texture in iOS

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates