css

[css] ์ด๋ฏธ์ง€์œ„์— button ์ถ”๊ฐ€ํ•˜๊ธฐ

natrue 2021. 2. 5. 23:14
728x90

 

position: relative; ์œ„์น˜๋ฅผ ๊ณ„์‚ฐํ• ๋•Œ static์˜ ์›๋ž˜ ์œ„์น˜๋ถ€ํ„ฐ ๊ณ„์‚ฐํ•œ๋‹ค.
position:
absolute;
์›๋ž˜ ์œ„์น˜์™€ ์ƒ๊ด€์—†์ด ์œ„์น˜๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋‹จ, ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์ƒ์œ„ ์š”์†Œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์œ„์น˜๊ฐ€ ๊ฒฐ์ • ๋œ๋‹ค.

 

 

<div id="testImg">
  <img src="/images/test.png" width="700" height="350" alt="ํ…Œ์ŠคํŠธ์ด๋ฏธ์ง€" />
  <button class="btn1" type="button" onclick="javascript:sensorBtnClick('btn1');">๋ฒ„ํŠผ1</button>
  <button class="btn2" type="button" onclick="javascript:sensorBtnClick('btn2');">๋ฒ„ํŠผ2</button>
</div>
<style>
#testImg{
  postiion : relative;
  width: 700px;
  height: 350px;
}
button.btn1 {
  position: absolute;
  top: 170px;
  left : 35px; 
}
button.btn2 {
  position: absolute;
  top: 85px;
  left : 95px;
}
</style>

 

 


๊ฒฐ๊ณผ