I'm using FireFox. I want to split a picture into 3 parts and then display only middle part using greasemonkey. Can someone please help me out... Thank You
            Asked
            
        
        
            Active
            
        
            Viewed 1,011 times
        
    1 Answers
3
            You could do it by setting the image as a background image and manipulating the size and background-position.
Here's how to do it using jQuery:
var img = /* get the image */
var width = Math.round(img.width() / 3.0);
var split = $('<div></div>')
    .css('background-image', 'url(' + img.attr('src') + ')')
    .css('background-position', '-' + width + 'px 0')
    .css('width', width + 'px')
    .css('height', img.height());
img.before(split)
   .hide();
I assume you want to split it horizontally, but it should be straightforward to convert this to split vertically.
See this question for how to use jQuery in GreaseMonkey.
 
    
    
        Community
        
- 1
- 1
 
    
    
        David Fullerton
        
- 3,224
- 27
- 38
