Привет, У меня есть элемент, который я хочу изменить, когда изменяется размер экрана. Я хочу, чтобы он изменился с фиксированной позиции на центр страницы. Код CSS выглядит так:
#symboler {
position:fixed;
top:5px;
right:20px;}
@media screen and (max-width: 766px) {
#symboler {display:block; position:relative; margin:0 auto;}
}
Вы ищете что-то вроде этой скрипки?
HTML
<div id="symboler"></div>
CSS
* {
margin: 0; // reset browser value
padding: 0; // reset browser value
}
#symboler {
position:fixed;
top:5px;
right:20px;
height: 200px; // just to display a red cube
width: 200px; // just to display a red cube
background: red; // just to display a red cube
}
@media screen and (max-width: 766px) {
#symboler {
display:block; // you can remove this if you are using a block element like div
position:relative;
margin:0 auto;
right:0; // reset your value
}
}
Попробуйте добавить
float:none;
width: 450px //specify width accurately in pixel or em
margin : 0 auto;
position:relative;
Проверьте это демо jsFiddle
#symboler {
position:fixed;
top:5px;
right:20px;
height: 200px;
width: 200px;
background: red;
}
@media screen and (max-width: 766px) {
#symboler {
display:block;
position:relative;
margin:0 auto;
right:0;
}
}