[英]Positioning an image with margin-top
on this page http://lafon.atelier47.fr/domaines-interventions i need to positioning the image with circle using margin-top, on large desktop the positioning is ok but when the screen is smaller the positioning is not ok. 在此页面上http://lafon.atelier47.fr/domaines-interventions我需要使用margin-top用圆形定位图像,在大型台式机上可以定位,但是在屏幕较小时则不能定位。 Perhaps there is a solution with css, javascript or jquery ? 也许有CSS,JavaScript或jquery的解决方案?
My Code: 我的代码:
#qx-image-4919 {
margin-top: -25%;
}
Use media query to change css values (in your case margin-top
) of image to whatever value you want. 使用媒体查询将图片的css值(在您的情况下为margin-top
)更改为所需的任何值。
@media (max-width:1200px){
#qx-image-4919 {
margin-top: -70%;
}
}
This will change the margin-top to -70% for all device screens that are less than 1200 pixels 对于所有小于1200像素的设备屏幕,这会将边距顶部更改为-70%
Read more about media queries here: 在此处阅读有关媒体查询的更多信息:
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
Best option here is to work with media queries . 最好的选择是使用媒体查询 。 I don't know at which stage you want it to kick in. There are several ways to setup your media queries. 我不知道您希望它进入哪个阶段。有几种方法可以设置媒体查询。 Try to paste this in your CSS: 尝试将其粘贴到您的CSS中:
@media (max-width: 600px) {
#qx-image-4919 {
margin-top: -25%; // your position when the screen is max 600px or smaller
}
}
First try with 首先尝试
!important
Else, Change your css code instead of % ;try with px 否则,请更改您的CSS代码而不是%;尝试使用px
Like 喜欢
margin-top: -200px !important;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.