2014-06-05 1 views
3

나는 고위 웹 사이트를 구축 중입니다. 페이지 상단에 버튼을 추가하여 모든 배경색을 제거하고 흰색으로 변경 한 다음 모든 텍스트 색상을 검은 색으로 변경하여 사이트의 친숙한 시각 장애가있는 시각을 제공했습니다. 기본적으로 대조 Swapper를 달성하려고합니다. 이 결과를 얻기 위해 jquery 함수를 작성하려고했습니다. 그러나이 작업을 수행 한 후 몇 시간이 지나서야 내가 생각해 낸 함수가 지나치게 복잡해졌으며 페이지에있을 수있는 많은 HTML 요소가 있으므로 원하는 결과를 제공하지 못합니다. jQuery 또는 Javascript에서 모든 html 요소를 선택하고 흰색 배경과 검은 색 텍스트를 적용하는 쉬운 방법이 있습니까? CSS에서이 작업을 수행 할 수있는 방법이 있다면 그 결과는 재사용 할 수 있어야합니다. 각 사이트를 수동으로 조정하지 않고이 기능을 500 개 이상의 사이트에 복사해야합니다.콘트라스트 (대조 Swapper) 웹 사이트의 모든 텍스트 및 배경 조정

답변

0
$('html *:not(script, style, noscript)').each(function() { 
    $(this).css("background", "none"); 
    $(this).css("background-color", "yellow"); 
    $(this).css("color", "black"); 
    $(this).css("box-shadow", "none"); 
    $(this).css("text-shadow", "none"); 
}); 

. 위의 코드는 배경을 노란색으로 변경하고 텍스트 색상을 흰색으로 변경합니다. 예를 들어 검정 바탕에 흰색, 검정색 바탕에 검정색, 검정색 바탕에 검정색과 같은 다른 동작을 수행하기 위해이를 수정할 수 있습니다.

0

대부분의 페이지는 <html> 태그에 클래스를 추가합니다. 그래서 당신은 클래스와 함께 2 개의 CSS를 만들 수 있습니다.

예 : 내 CSS 중 하나를 수정하지 않고 이러한 목표를 달성하기 위해 jQuery 코드 위를 사용할 수 있었다 http://jsfiddle.net/7RVWG/

-2
import java.awt.*; 
import javax.swing.*; 

public class Test3 implements Icon 
{ 
    public static final int NONE = 0; 
    public static final int DECENDING = 1; 
    public static final int ASCENDING = 2; 

    protected int direction; 
    protected int width = 8; 
    protected int height = 8; 

    public Test3(int direction) 
    { 
     this.direction = direction; 
    } 

    public int getIconWidth() 
    { 
     return width+1; 
    } 

    public int getIconHeight() 
    { 
     return height+1; 
    } 

    public void paintIcon(Component c, Graphics g, int x, int y) 
    { 
     Color bg = c.getBackground(); 
     Color light = bg.brighter(); 
     Color shade = bg.darker(); 

     int w = width; 
     int h = height; 
     int m = w/2; 
     if (direction == ASCENDING) 
     { 
      g.setColor(shade); 
      g.drawLine(x, y, x + w, y); 
      g.drawLine(x, y, x + m, y + h); 
      g.setColor(light); 
      g.drawLine(x + w, y, x + m, y + h); 
     } 
     if (direction == DECENDING) 
     { 
      g.setColor(shade); 
      g.drawLine(x + m, y, x, y + h); 
      g.setColor(light); 
      g.drawLine(x, y + h, x + w, y + h); 
      g.drawLine(x + m, y, x + w, y + h); 
     } 
    } 

    public static void main(String[] args) 
    { 
     Test3 t=new Test3(5); 
     t.paintIcon(20,10,5,5); 
    } 
} 
관련 문제