Requesting help in jQuery or CSS.

70 views Asked by At

The background color, font color and border are being lost when I drop an element. How do I keep these properties intact? Here is the project in jsFiddle:

http://jsfiddle.net/n2learning/tV4n7/48/

Thanks!

6

There are 6 answers

0
Pat On BEST ANSWER

Just needed a minor change to your CSS. I've removed the #routinefilter from this rule so it applies to all .droptrue elements, no matter what their parent element is:

.droptrue{
    background: lightgray;
    color: navy;
    margin:10px;
    padding:5px;
    border:2px solid #666;
}

Here's the working example.

0
David Thomas On

Your CSS selector was specific to the point of origin, but not to the dropping-point. Add #dropTargetframe .droptrue to your selector, to give:

#routinefilter .droptrue,
#dropTargetframe .droptrue {
    background: lightgray;
    color: navy;
    margin:10px;
    padding:5px;
    border:2px solid #666;
}

Updated JS Fiddle.

Or you could simply remove the ancestor id from the selector, to give simply:

.droptrue {
    background: lightgray;
    color: navy;
    margin:10px;
    padding:5px;
    border:2px solid #666;
}

Updated JS Fiddle demo.

0
kitti On

Your CSS rule:

#routinefilter .droptrue{

only applies to elements with a class droptrue WHILE they are in the container routinefilter. Once you drop them in the box, they are no longer inside routinefilter and the rule doesn't apply. Try changing that to just:

.droptrue{
0
Msonic On

This should do the trick.

#routinefilter .droptrue, #dropTargetframe .droptrue{
    background: lightgray;
    color: navy;
    margin:10px;
    padding:5px;
    border:2px solid #666;
}

The .droptrue elements will keep the same css style when inside the box as well!

Edit: You can also change it to only .droptrue if you want those boxes to use this style wherever they are.

0
Kisaro On

Change

    #routinefilter .droptrue

into

    .droptrue

Edit: Whoops, too late :)

0
Zoli On

Add to CSS

.droptrue
{
    font: 16px serif 
    background: none repeat scroll 0 0 lightgray;
    border: 2px solid #666666;
    color: navy;
    margin: 10px;
    padding: 5px;
}