본문 바로가기

html15

[JavaScript] table에서 내용을 title 속성에 자동으로 추가 table 태그 내 td 안의 내용을 td의 title 속성에 자동으로 추가하여 툴팁(tooltip)으로 보여주는 방법 [html] header header header header content 1 content 2 content 3 content 4 content 5 content 6 content 7 content 8 content 9 content 10 content 11 content 12 [css] table, th, td { border: 1px solid #222; } [js] window.onload = function() { // 화면 로딩 후 실행 let tds = document.querySelectorAll('td'); // td 태그 배열로 변수에 할당 tds.forEach((i.. 2024. 1. 24.
[jQuery] 마우스 커서(cursor) 따라다니는 애니메이션(animation) 마우스 커서(cursor)를 따라다니는 도형 애니메이션(animation) [html] [css] .cursor { position: absolute; transform: translate(100%, 100%); width: 1rem; height: 1rem; border: 2px solid #808080; border-radius: 50%; opacity: 0.4; transition: all 0.3s ease-out; z-index: 1000; } .cursor.on { border: 2px solid #222; background: #222; opacity: 1; } [js] $(window).on('scroll mousemove', function(e){ $('.cursor').css('left'.. 2023. 8. 11.
[jQuery] data-tab 활용 탭 메뉴(tabs menu) data-tab 을 활용한 탭 메뉴(tabs menu) 구현 [html] menu1 menu2 menu3 menu 1 menu 2 menu 3 [css] *{ margin: 0; padding: 0; } ul{ display: flex; gap: 20px; position: relative; } li{ list-style: none; } li.on a{ font-weight: bold; color: red; } .content{ display: none; width: 300px; height: 300px; padding: 10px; margin-top: 10px; border: 1px solid black; } .content.on{ display: block; } [js] $('li').click(fu.. 2023. 8. 5.
[CSS] 텍스트(text)에 배경색(background) 적용 텍스트에 배경색 클리핑 마스크(clipping mask) 적용 [html] Clipping Mask BACKGROUND BACKGROUND [css] * { margin: 0; padding: 0; } h2 { /* 배경 그라데이션 */ background: rgb(34,193,195); background: linear-gradient(0deg, rgba(34,193,195,1) 0%, rgba(253,187,45,1) 100%); text-align: center; /* 텍스트에 배경색 적용 */ color: transparent; background-clip: text; -webkit-background-clip: text; } section { display: grid; grid-template-.. 2023. 8. 3.
[swiper] slide 실행 시 콜백(callback) 이벤트 스와이퍼 슬라이드 실행 시 이벤트 설정 [html] Slide 1 Slide 2 Slide 3 Slide 4 Slide 5 [css] .swiper { width: 300px; height: 200px; } .swiper-slide { background: skyblue; text-align: center; } .text{ width: 300px; height: 100px; margin: 0 auto; } [js] var swiper = new Swiper(".mySwiper", { navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, speed: 1000, loop: true, on: { slideChange: fu.. 2023. 7. 19.
[JavaScript] forEach 활용 탭 메뉴 (Tabs) 구성 자바스크립트의 forEach를 활용하여 탭 메뉴 구성하기 [html] tab1 tab1 content tab2 tab2 content tab3 tab3 content [css] ul { position: relative; padding: 0; } li { list-style: none; } a{ color: inherit; text-decoration: none; } .tab-menu { display: flex; justify-content: space-between; width: 200px; } .tab.active { color: red; text-decoration: underline; } .content { display: none; position: absolute; left: 0; top: .. 2023. 7. 8.
[CSS] 반응형 비율 유지 박스(responsive box) css를 활용하여 반응형에서 가로/세로 2:1 비율을 유지하는 박스 만들기 [html] 2:1 box box1: width 15% box1: width 20% 1. 패딩값(padding) 사용 [css] .box1{ width: 15%; background: yellowgreen; } .box1::after{ content: ""; display: block; padding-top: 50%; /* 예) 1:1 박스의 경우 100% 입력 */ } 2. aspect-ratio 사용 [css] .box2{ width: 20%; aspect-ratio: 2 / 1; background: skyblue; } See the Pen [CSS] responsive box ratio _ 반응형 박스 비율 유지 by Ji.. 2023. 7. 3.
[CSS] scroll bar design _ 스크롤바 디자인 [html] Lorem ipsum dolor sit amet consectetur adipisicing elit. Exercitationem excepturi laborum quidem ullam quae, magni temporibus magnam quasi adipisci laudantium natus voluptatum facere cum. Distinctio corporis porro eos odit sed? [css] div{ width: 200px; height: 200px; outline: 1px solid red; overflow-y: scroll; } div::-webkit-scrollbar{ /* 스크롤바 배경 */ width: 20px; border-radius: 10px; backg.. 2023. 6. 30.
[jQuery] 스크롤(scroll) 방향 감지 이벤트 제이쿼리(jQuery)를 이용하여 스크롤(scroll) 감지 이벤트 만들기 스크롤 방향에 따라 헤더(header) 숨김/표시 예시 [html] header [css] header{ position: fixed; width: 100%; height: 100px; background: pink; } main{ width: 100%; height: 1000px; background: skyblue; } [js] let lastScroll = 0; // 초기 스크롤 위치 $(window).scroll(function(){ let nowScroll = $(this).scrollTop(); // 현재 스크롤 위치 if (nowScroll > lastScroll) { // 스크롤 위치 증가 $('header').st.. 2023. 6. 14.
728x90