简体   繁体   English

在不同计算机上的相同位置

[英]Same position on different computers

I have some images on my page that looks fine on my mac but when I open the page on a different computer the positions of the elements is completely different. 我的页面上有一些图像,在Mac上看起来不错,但是当我在另一台计算机上打开页面时,元素的位置完全不同。 Also I have the same problem with text placement, on my computer the text is for example 3cm from the edge of the page but on a different screen it's not right. 另外,我在文字放置方面也遇到了同样的问题,例如,在我的计算机上,文字距页面边缘3cm,但在其他屏幕上则不正确。 Here is a snippet of the code. 这是代码片段。

IMAGE PLACEMENT: 图像位置:

HTML 的HTML

<img src="las.jpg" width=660px height="auto" class="center"/>

CSS file CSS文件

.center{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: -10%;
}

TEXT PLACEMENT: 文字位置:

HTML 的HTML

<p><i><b>Park Narodowy</b> - "obejmuje obszar wyróżniający się szczególnymi `wartościami przyrodniczymi, naukowymi, społecznymi, kulturowymi i edukacyjnymi, o powierzchni nie mniejszej niż 1000 ha, na którym ochronie podlega cała przyroda oraz walory krajobrazowe." <br></i></p>

CSS file: CSS文件:

p{

position: absolute; left: 8cm;
right: 8cm;
text-align: justify;
}

Different computers means different screen size, but also different navigators. 不同的计算机意味着不同的屏幕尺寸,但导航器也不同。

In css, using the auto value means that you really on the browser default stylesheet to handle the parameter, in your case the left and right margins. 在css中,使用auto值意味着您实际上是在浏览器默认样式表上处理该参数,在这种情况下为左右空白。

auto 汽车

The browser selects a suitable margin to use. 浏览器选择合适的边距来使用。 For example, in certain cases this value can be used to center an element. 例如,在某些情况下,此值可用于使元素居中。

from https://developer.mozilla.org/en-US/docs/Web/CSS/margin 来自https://developer.mozilla.org/en-US/docs/Web/CSS/margin

Also, when using relative units such as percentage, the value will differ according to screen and window size, causing different behaviors. 此外,当使用相对单位(例如百分比)时,该值将根据屏幕和窗口大小而有所不同,从而导致不同的行为。 You can use absolute units such as pixels to avoid this issue. 您可以使用绝对单位(例如像素)来避免此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM