2015. 11. 17. 14:31

- 모바일 a링크 클릭시 영역을 나타내는 하이라이트 제거방법





 -webkit-tap-highlight-color: transparent;


** 여기서 하이라이트 배경색도 변경 가능하다!


Posted by miLove
2015. 10. 13. 13:38

html

 
  

css

 
   .banner_wrap{position:relative; padding:100px}
	.banner_wrap .btn{display:block; width:50px; height:50px; position:absolute; left:30px; top:120px;}
	.banner_wrap .btn.btn_next{position:absolute; left:330px; top:120px;}
	.banner_wrap .banner{overflow:hidden; width:200px; height:100px}
	.banner_wrap .banner ul{*zoom:1; wid th:600px;}
	.banner_wrap .banner ul:after{display:block; content:""; clear:both;}
	.banner_wrap .banner ul li{float:left; width:200px; height:100px; background-color:#fff;}
	.indicator{width:200px; margin-top:10px; text-align:center;}
	.indicator a{display:inline-block; margin:0 2px; border:1px solid #fff; width:14px; height:14px; border-radius:10px; background-color:#fff;}
	.indicator a.on{border:1px solid #bc6848;  background-color:#bc6848; }

jquery

 
 $(document).ready(function(){
	// li갯수
	var liLength = $(".banner ul li").size();

	// ul 넓이
	var ulWidth = 200* liLength
	$(".banner ul").css("width",ulWidth+"px")

	// 좌우 버튼 
	$(".btn_prev").click(function(){
		if($(".banner ul").css("margin-left") == "0px"){
			$(".banner ul").css("margin-left","0");
			indicator();
		}else{
				//조건시작
				if(!$(".banner ul").is(":animated")){
					$(".banner ul").animate({"margin-left":"+=200"},500,function(){
						indicator();
					});
				}
				//조건끝		
			}
	});
	
	$(".btn_next").click(function(){
		if($(".banner ul").css("margin-left") == "-"+(ulWidth-200)+"px"){
			$(".banner ul").css("margin-left","-"+(ulWidth-200)+"px");
			indicator();
		}else{
			//조건시작
			if(!$(".banner ul").is(":animated")){
				$(".banner ul").animate({"margin-left":"-=200"},500,function(){	
					indicator();
				});	
			}
			//조건끝			
		}	
	});
	
	// indicator Length
	for(var i=0 ; i");
		}else{
			$(".indicator").append("");
		}
	}

	// indicator index 
	$(".indicator a").click(function(){
		var paging = $(this).index();
		$(".banner ul").animate({"margin-left":paging*-200+"px"},500);
		$(".indicator a").removeClass("on");
		$(".indicator a").eq(paging).addClass("on");
	});

	//좌우indicator 함수
	function indicator(){
		var leftPosition = parseInt($(".banner ul").css("margin-left"));	//parseInt 숫자값으로 변환 	
		var anchorIndex = -(leftPosition/200);
		//var anchorIndex = Math.abs(leftPosition/200);
		$(".indicator a").removeClass("on");
		$(".indicator a").eq(anchorIndex).addClass("on");	
		//$(".indicator a").eq(-( parseInt($(".banner ul").css("margin-left"))/200)).addClass("on"); 
	}
	
});
Posted by miLove
2015. 9. 11. 18:02

rem(root em)  


px처럼 고정단위가 아닌 유연한 가변 단위로서 rem에 대하 알아 보기! 
em : 부모기준
rem : html기준 html요소에 글자크기를 한번 지정하고, 나머지는 그 비율에 따라 크기를 지정








100% = 16px = 1rem
2rem= 32px

그럼 18px일때는....................1.13rem 

계산하기가 너무 힘든데?

그래서 찾아보왔더니 






참고 사이트 : http://snook.ca/archives/html_and_css/font-size-with-rem




62.5% = 10px = 1rem

그럼

24px 일때는 2.4rem


테스트를 해보왔다.







html에 62.5%로 기준을 잡아야 rem계산하기기 쉽다 는걸 볼수있다.

위에서도 말했듯이 rem은 html 기준이여서 같은 1rem이여도 부모 폰트에 따라 자식은 달라진다.
그러므로 부모의 기준은 계산하기 쉬운 62.%로 해얀다는걸 알았다.




 브라우저











'Tip' 카테고리의 다른 글

css - initial / inherit / 상속된 css 사용시 초기화할 때  (0) 2015.09.02
[Tip] IR기법과 IS기법  (0) 2014.05.30
em계산법  (0) 2014.01.29
Posted by miLove
2015. 9. 2. 16:20


가끔 상속된 css를 사용하여 오버라이딩 할때 부모에게 먹은 속성값을 해지 해야할 경우 

initial  / inherit  css에 기본으로 있는 두 속성을 볼수 있다.



 initial  : 초기값 

  • ie8에서 지원
  • initial 되도록 사용 안하는게 좋음 ! ie에서 속성표시안됨(Not supported)
  • default값을 이용하려는 경우 에는 최대한 그 태그에 대한 기본 속성을 사용하는게 좋다.

initial  태그를 잘못 사용해서 디폴드 값으로 사용하면 다른페이지에도 영향을 줄수가 있고, 초기값으로 만들기때문에 ... 사용은 되도록 안하는게 좋다.






inherit : 부모 요소에서 값을 상속하도록 지정 


  • i7 지원안됨 / ie8에서 독타입 선언을 통해 지원
  • border, margin, padding, float, position 등의 속성은 하위 요소에 상속되지 않는다.


★ 그럼 상속된 css를 default값으로 이용할때 TIP


  • width : auto
  • background-color : transparent
  • min-width :  inherit or auto

auto 나 none 기본으로 속성에 존재하는걸로 초기화 하는게 좋고, initial  을 되도록 사용 안하는걸로!


'Tip' 카테고리의 다른 글

rem단위  (0) 2015.09.11
[Tip] IR기법과 IS기법  (0) 2014.05.30
em계산법  (0) 2014.01.29
Posted by miLove
2015. 8. 28. 17:38

4. 탭메뉴 리스트 속에 컨텐즈 존재하게 !! li 안에 div 구조로

html

 
  • 1번탭내용
  • 2번탭내용
  • 3번탭내용
  • 4번탭내용




css

 
   ul,li{list-style:none}
	.tab{position:relative;overflow:hidden;height:500px}
	.tab li{float:left;width:63px;border:1px solid #fff}
	.tab li a{display:block;width:63px;height:50px;line-height:50px;text-align:center}
	.tab li  div{display:none; width:100%;height:500px;position:absolute;left:100px;top:100px;}
	.tab li:nth-child(2) div{display:none}
	.tab li:nth-child(3) div{display:none}
	.tab li:nth-child(4) div{display:none}
	.tab li.on div{display:block;}

js

 
$(function(){
	 $(function(){
	$('.tab li').click(function(){
		var tabType = $(this).index();
		
		$('.tab li').each(function(index){
			$(this).find('img').attr('src', $(this).find('img').attr('src').replace('_off','_on'));
			
			if(tabType != index){
				$(this).find('img').attr('src', $(this).find('img').attr('src').replace('_on','_off'));
			}

		});

			
			//on class 없이도 제어  
			//$('.tab div').hide();
			//$('.tab div').eq(tabType).show();


		//class li에 on제어 
		$('.tab li').removeClass('on');
		$('.tab li').eq(tabType).addClass('on');	



	});


 });




css로 on 클레스 만들어서 사용하는게 더 효과적이다. !



Posted by miLove
2015. 8. 28. 17:32

3. 이미지로 된 탭메뉴

html

1번탭내용
2번탭내용
3번탭내용
4번탭내용

css

 
 ul,li{list-style:none}
	.tab{overflow:hidden}
	.tab li{float:left;width:63px;border:1px solid #fff}
	.tab li a{display:block;width:100%;height:50px;line-height:50px;text-align:center}
	.con_wrap{position:relative;height:200px;border:1px solid red}
	.con_wrap div{position:absolute;left:0;top:0;}
	.con_wrap div:nth-child(2){display:none}
	.con_wrap div:nth-child(3){display:none}
	.con_wrap div:nth-child(4){display:none}

js

 
$(function(){
	$('.tab li').click(function(){
		
		var tabType = $(this).index();
		
			$('.tab li').each(function(index){
			$(this).find('img').attr('src', $(this).find('img').attr('src').replace('_off','_on'));
			if(tabType != index){
				$(this).find('img').attr('src', $(this).find('img').attr('src').replace('_on','_off'));
			}
		});

			$('.con_wrap>div').eq(tabType).show().siblings('div').hide();

	});


 });
Posted by miLove
2015. 8. 26. 17:53

2. 클래스없이 탭메뉴

html


1번탭내용
2번탭내용
3번탭내용
4번탭내용

css

 ul,li{list-style:none}
	.tab{overflow:hidden}
	.tab li{float:left;width:33%;border:1px solid #fff}
	.tab li a{display:block;width:100%;height:50px;line-height:50px;background:pink;text-align:center}
	.tab li a.on{background:blue}
	.con_wrap{position:relative;height:200px;border:1px solid red}
	.con_wrap div{position:absolute;left:0;top:0;}
	.con_wrap div:nth-child(2){display:none}
	.con_wrap div:nth-child(3){display:none}
	.con_wrap div:nth-child(4){display:none}

js

 
$(function(){
	$(".tab li").click(function(){
		

		var tabType = $(this).index();
		
		$('.con_wrap div').hide();
		$('.con_wrap div').eq(tabType).show();

		$('.tab a').removeClass('on');
		$('.tab a').eq(tabType).addClass('on');	
		
	})


 });

* TIP 

1. 선택한 태그가 몇번째 위치지인지 알수 있는 함수 

2. 특정 위치를 찾는 함수 




eq(n) : n번째로 일치하는 엘리먼트




Posted by miLove
2015. 8. 25. 11:21

1. 앵커로 탭메뉴

html


1번탭내용
2번탭내용
3번탭내용
4번탭내용

css

ul,li{list-style:none}
	.tab{overflow:hidden}
	.tab li{float:left;width:33%;border:1px solid #fff}
	.tab li a{display:block;width:100%;height:50px;line-height:50px;background:pink;text-align:center}
	.con_wrap{position:relative;height:200px;border:1px solid red}
	.con_wrap .con{position:absolute;left:0;top:0}
	.con_wrap .con:nth-child(2){display:none}
	.con_wrap .con:nth-child(3){display:none}
	.con_wrap .con:nth-child(4){display:none}

js

$(function(){
	$(".tab a").click(function(){
		
		var tabType=$(this).attr('href');
		$(tabType).show().siblings(".con").hide();
        })


 });

- click() 이벤트

클릭을 하면 이벤트를 발생


- attr() 메소드

attr(attribute) = attr(속성); - 속성의 값 가져오기

attr(attribute,value) = attr({속성:값, 속성:값}); - 대상의 속성을 값으로 설정

Posted by miLove
2014. 6. 19. 20:59

web용
- web에선 1줄 말줄임만 허용된다. ie7~ 모든브라우저에서 사용할수있다.
- width값으로 제어를 합니다.


[css]
  1. overflow: hidden;
  2. white-space: nowrap;
  3. text-overflow: ellipsis;
width
  1. width: 100px;



table
- 테이블에 텍스트로 길게 들어가는 부분에는 넓이가 colgroup에 없는데 그때 사용할수있다 

[html]
<table class="tbl">
   <caption><span class="blind">내가 쓴 덧글  목록</span></caption>
   <colgroup>
   <col style="width:94px">
   <col>
   <col style="width:67px">
   <col style="width:68px">
   <col style="width:94px">
   </colgroup>
   <thead>
   <tr>
   <th scope="col">쿠폰명</th>
   <th scope="col">이벤트명</th>
   <th scope="col">지급일</th>
   <th scope="col">사용가능기간</th>
   <th scope="col">받은아이템</th>
   </tr>
   </thead>
   <tbody>
   <tr>
    <tr>
   <td class="cp"><span>쿠폰명</span></td>
   <td class="evt"><a href="#">이벤트명이벤트명이벤트명이벤트명</a></td>
   <td class="date">12.03.15</td>
   <td class="date"> ~ 13.03.15</td>
   <td class="item">무기업그레이드</td>
   </tr>
   </tbody>
   </table>

[css]
            .my_info .tbl{
          1. table-layout: fixed;
          }

          .tbl .evt{
          1. overflow: hidden;
          2. white-space: nowrap;
          3. text-overflow: ellipsis;

          }



          mobile


          모바일_1줄 이상 말줄임 적용

          overflow: hidden;

          display: -webkit-box;

          -webkit-line-clamp: 4;/몇번째 줄에서 말줄임?

          -webkit-box-orient: vertical;

          word-wrap: break-word;



          Posted by miLove
          2014. 5. 30. 12:18



          IR(Image Replacement)

          의미가 포함되어 있는 이미지를 배경으로 처리하고 대신 전경에 상응하는 텍스트를 넣는 방법으로써 시각이 있는 사용자는 이미지로 처리된 화면을 볼 수 있지만 '화면 낭독기를 사용하는 시각 장애인, CSS 제거, 인쇄' 시에는 텍스트 데이터에 접근하거나 텍스트를 볼 수 있는 형태로 설계하는 기법을 말합니다. 이 기법의 장점은 접근성을 떨어뜨리지 않으면서도 검색엔진으로부터 높은 가중치를 받을 수 있다는 점 입니다. 한편 모바일 브라우징 장치에서 전송 요금 등을 고려하여 일부러 이미지를 끈 상태로 웹 사이트를 이용하는 사용자에게는 이미지와 텍스트가 모두 출력되지 않기 때문에 치명적일 수 있습니다. 따라서 의미가 포함된 이미지는 전경으로 처리한다는 원칙을 먼저 세우고 여러 조각의 이미지가 전송 성능에 영향을 미치지 않도록 고려해야 하는 경우에만 Sprite(조각난 이미지들을 하나의 이미지로 배경 처리해서 전송 성능을 높이는) 기법과 함께 사용하는 것이 좋습니다.

          ★ 의미가 포함된 이미지를 배경으로 처리하고 그내용을 텍스토 넣은후 css로 숨기는 기법


          IS(Image Sprite)
          조각난 이미지 파일들을 하나의 파일로 병합 후 배경으로 처리해서 웹 문서 전송 속도를 높이는 기법 입니다. 이 때 의미가 있는 이미지는 전경에 상응하는 텍스트를 포함시켜서 접근성을 확보해야 하기 때문에 IR(Image Replacement) 기법이 함께 사용 됩니다.

          ★ 이미지들을 하나의 이미지로 배경 처리해서 최적화 시킬수 있는 기법


          [Tip] 내생각 정리
           

          1. 무조건 한파일로 할 필요는 없다. 이미지들의 종류와 사용방법에따라 나눠서 하는게 좋다.
          2.스프라이트 기법을 사용하는게 맞는지 하나의 이미지로 가는게 맞는지 잘생각하고 사용해야한다.
          3.스프라이트 기법을 사용하는 이유는 홈페이지 최적화를 위해 사용하는데 이미지간에 간격을 너무 많이 띄어서 사용하면, 그걸 쓰는 이유는 없어진다. 간격을 많이 띄면 코딩하기는 편해지지만 ... 그건 사용하나 안하나.. 똑같아지기때문에..

          'Tip' 카테고리의 다른 글

          rem단위  (0) 2015.09.11
          css - initial / inherit / 상속된 css 사용시 초기화할 때  (0) 2015.09.02
          em계산법  (0) 2014.01.29
          Posted by miLove
          2014. 2. 3. 10:28

          요소 선택자

          :first-child /* 첫번재*/
          :last-child /*마지막*/
          
          :nth-child() /*가로안에 숫자를 집어넣어서 몇번째인지 정한다*/
          :nth-child(5n+1) /* 5개씩 자르고 그중 첫번째이다.(숫자는마음대로)*/
          div:nth-child(5n) /*5개씩 자르고 그중 5번째이다*/
          :nth-child(odd) /*홀수*/
          :nth-child(even) /*짝수*/
          :nth-of-type(숫자) /*nth-child랑 비슷한데 다른점은 dl dt dd 같이 묶여있는건 nth-child 가 반응을못한다 그땐 nth-of-type()을 쓰면 된다*/
          :not(:first-child) /*첫번째께 아닐경우*/
          
          Posted by miLove
          2014. 1. 29. 10:46

          ★em 계산방법

          모바일 해상도가 1080px로 나왔을경우 ,
          아이폰: 1080/320=3.375
          갤럭시 4s부터 : 1080/480=2.25

          ex) font50px를 em으로 계산하려면

          body : 14px =1em
          50/3.375/14 =1.06
          50/2.25/14 =1.59

          여기서 아이폰 사이즈만 잡고 미디어 커리로 제어를 해줘도 된다 !

          css

          /*DPI 480*/
          @media only screen and (-webkit-min-device-pixel-ratio: 2.5){
          	body {font-size:16px;}
          }
          

          ★em 으로 작업시 ul>li>ul>li가나올경우 (자식이 부모에게 상속되서 엄청 작게나온다 그럴경우)

          부모 ul : 34px

          자식 ul : 30px
          자식 ul클릭하고 크롬에서 수치값을 본다

          ex)만약 수치값이 10px로 나온경우
          계산법 : 30px / 3.375/ 10px(수치값) = 0.89em 그다음 0.89em/10px(나자신의 수치값) * 14px(body 또는 부모값)

          'Tip' 카테고리의 다른 글

          rem단위  (0) 2015.09.11
          css - initial / inherit / 상속된 css 사용시 초기화할 때  (0) 2015.09.02
          [Tip] IR기법과 IS기법  (0) 2014.05.30
          Posted by miLove