在CSS中拖放时更改光标样式 [英] Change cursor style when drag and drop in css

查看:151
本文介绍了在CSS中拖放时更改光标样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对图像排序进行拖放,代码工作得很好,但是现在客户端希望当用户拖动行时,光标样式是指针".

I make a drag and drop on image sorting, the code work very well, but now client want that when a user Drag row the cursor style is a "pointer".

现在默认光标样式为移动".我更改了CSS中的所有位置,但徒劳无功.

Now default cursor style is "move". I change every where in css but in vain, no changing happen.

任何人都可以使用CSS.

Can any one help with css.

任何建议.

这是我的代码

<table class="widefat fixed" cellspacing="0" id="image_sort" style="width:100%; table-layout:inherit;">
        <thead>
            <tr>
                <th scope="col" class="column-slug"><?php _e('Image','lgs') ?></th>
                <th scope="col"><?php _e('Image Links To','lgs') ?></th>
                <th scope="col" class="column-slug"><?php _e('Actions','lgs') ?></th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th scope="col" class="column-slug"><?php _e('Image','lgs') ?></th>
                <th scope="col"><?php _e('Image Links To','lgs') ?></th>
                <th scope="col" class="column-slug"><?php _e('Actions','lgs') ?></th>
            </tr>
        </tfoot>

        <tbody>

        <form method="post" action="options.php">
        <?php settings_fields('wp_logo_slider_images'); ?>
        <?php foreach((array)$wp_logo_slider_images as $image => $data) : ?>
            <tr id="list_item_<?php echo $image ?>" class="list_item">
                <input type="hidden" name="wp_logo_slider_images[<?php echo $image; ?>][id]" value="<?php echo $data['id']; ?>" />
                <input type="hidden" name="wp_logo_slider_images[<?php echo $image; ?>][file]" value="<?php echo $data['file']; ?>" />
                <input type="hidden" name="wp_logo_slider_images[<?php echo $image; ?>][file_url]" value="<?php echo $data['file_url']; ?>" />
                <input type="hidden" name="wp_logo_slider_images[<?php echo $image; ?>][thumbnail]" value="<?php //echo $data['thumbnail']; ?>" />
                <input type="hidden" name="wp_logo_slider_images[<?php echo $image; ?>][thumbnail_url]" value="<?php echo $data['thumbnail_url']; ?>" />
                <th scope="row" class="column-slug"><img src="<?php echo $data['thumbnail_url']; ?>" /></th>
                <td><?php //echo $image; ?><input type="text" name="wp_logo_slider_images[<?php echo $image; ?>][image_links_to]" value="<?php echo $data['image_links_to']; ?>" size="30" /></td>
                <td class="column-slug"><input type="submit" class="button-primary" value="Update" /> <a href="?page=wp_logo_slider&amp;delete=<?php echo $image; ?>" class="button">Delete</a></td>
            </tr>
        <?php endforeach; ?>
        <input type="hidden" name="wp_logo_slider_images[update]" value="Updated" />
        </form>

        </tbody>
    </table>

<?php

function image_sort(){  
wp_enqueue_script('jquery');
?>
<!--<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>-->
<?php 
wp_enqueue_script('jquery-ui-sortable');
?>
<script type="text/javascript">

jQuery(document).ready( function(e) {
   jQuery('#image_sort').sortable({
            items: '.list_item',
            opacity: 0.5,
            cursor: 'move',
            axis: 'y',
            update: function() {
                var ordr = jQuery(this).sortable('serialize') + '&action=list_update_order';
                jQuery.post(ajaxurl, ordr, function(response){
                    //alert(response);
                });
            }
      });
});

</script>
<?php
    }
    add_action('admin_head','image_sort');

    function order_list(){
        global $wp_logo_slider_images;

        $list = $wp_logo_slider_images;
        $new_order = $_POST['list_item'];
        $new_list = array();

        foreach($new_order as $v){
            if(isset($list[$v])){
                $new_list[$v] = $list[$v];
            }
        }
        update_option('wp_logo_slider_images',$new_list);
    }
    add_action('wp_ajax_list_update_order','order_list');
?>

推荐答案

这可以使用 :active 伪类.

This can be done using :active pseudo class.

div{
    width: 300px;
    height: 300px;
    background-color: cornflowerblue;
}

div:active{
    cursor: pointer !important;
}

工作小提琴

Working Fiddle

这篇关于在CSS中拖放时更改光标样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆