본문 바로가기
프로그램 개발(분석, 설계, 코딩, 배포)/2.1.2 web_css

web_css_class 사용법

by 3604 2023. 1. 8.
728x90

class   사용법

 

<html>
<head>

<title>css</title>
<meta charset="utf-8">
<!--모바일에서도 동일하게 사용 viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<!--사용자도 작업자와 동일한 환경에서 볼 수있도록 설정-->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,italic,400italic,600,600italic,700,700italic,800,800italic">
<!-- css 소스 분리 방식-->
<!--<link href="style.css" rel="stylesheet" type="text/css">-->

<!-- css 소스 삽입 방식-->
<style>

body{
margin: 20px;
padding: 20px;
line-height: 1;
font-family: 'Open Sans', 'sans-serif';
font-size: 1em;
background-color: #555;
}
ul{
margin: 0;
padding: 0;
list-style: none;
}
    .title{
margin: 0;
padding: 0;
font-size: 1.5em;
font-weight: 300;
}
.container{
position: relative;
margin-top: 35px;
}
.box_group div{
margin: 10px;
padding: 10px;
width: 100px;
height: 100px;
border: 1px solid #000;
}
    /* class 가 있는 div일 경우*/
/*
.box_group div[class]{
background-color: #8ac007;
}
*/    

/* class 가 있는 box1인 경우*/
/*
.box_group div[class=box-2]{
background-color: #8ac007;
}
*/
/* current 클래스가 있는 경우*/

/*
.box_group div[class=current]{
background-color: #8ac007;
}
*/

/* 맨 앞 부분의 box를 제외하고 나머지 box에 속성 적용*/

/*
.box_group div[class^=box]{
background-color: #8ac007;
}
*/

/* 문자 중에서 '-1'이 포함된 경우*/

/*
.box_group div[class*="-1"]{
background-color: #8ac007;
}
*/

/* 문자 중에서 '-1'이 포함된 경우*/

.box_group div[class*="-1"]{
background-color: #8ac007;
}

</style>
</head>

<body>
<h1 class="title">css selector</h1>

<div class="container">
<div class="box_group">
<div class="current box-1">box</div>
<div class="box-2">box</div>
<div class="box-3">box</div>
<div class="box-4">box</div>
<div class="box-5">box</div>
</div>

</div>
</body>

</html>

728x90