html - Place circle at middle-right corner of div -
i have been trying place circle, position fixed @ middle of right corner of div.
the problem is: when resize browser, circle changes position. here code:
html:
<!doctype html> <html> <head> <title>test</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="black-box"> <span class="circle"></span> </div> </body> </html> css:
#black-box { position: fixed; width: 28.3%; left: 0; top: 0; bottom: 0; background: black; opacity: 0.7; filter: alpha(opacity=50); z-index: 3; -webkit-filter: blur(1px); -moz-filter: blur(1px); -o-filter: blur(1px); -ms-filter: blur(1px); filter: blur(1px); } /* "black box" circle */ .circle:before { position: fixed; top: 41%; left: 26.6%; content: '\25cf'; font-size: 100px; opacity: 1; filter: alpha(opacity=100); color: orange; } i wish circle, keeps position @ right place, if browser resized.
thanks in advance.
since using percentages widths, change when width of screen changes. instead recommend using widths in pixels. can add media queries change width @ breaking points. ensure circle never moves. see code below:
#black-box { position: fixed; width: 420px; left: 0; top: 0; bottom: 0; background: black; opacity: 0.7; filter: alpha(opacity=50); z-index: 3; -webkit-filter: blur(1px); -moz-filter: blur(1px); -o-filter: blur(1px); -ms-filter: blur(1px); filter: blur(1px); } /* "black box" circle */ .circle:before { position: fixed; top: 50px; left: 390px; content: '\25cf'; font-size: 100px; opacity: 1; filter: alpha(opacity=100); color: orange; } <!doctype html> <html> <head> <title>test</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="black-box"> <span class="circle"></span> </div> </body> </html>
Comments
Post a Comment