Dies ist eine statische Kopie unseres alten Forums. Es sind keine Interaktionen möglich.
This is a static copy of our old forum. Interactions are not possible.

Neo

Erfahrener Schreiberling

  • "Neo" is male
  • "Neo" started this thread

Posts: 322

Date of registration: Jul 24th 2005

Location: Hannover

Occupation: Informatik

1

Wednesday, March 31st 2010, 11:36pm

CSS, Pixel, Dezimalangaben

Hallo Forum,

sind halbe Pixel angaben im CSS logisch? Beispiel:

Source code

1
2
3
div {
  margin-top:11.5px;
}


Das scheint doch unlogisch? Ein Pixel ist ein Pixel. Der Bildschirm kann keine halben Pixel darstellen. Werden halbe Pixel CSS intern irgendwie zusammengerechnet, oder werden die Abstände einfach gerundet?

Edit: Bei genauem hinsehen scheint der Browser .5 angaben aufzurunden.

This post has been edited 1 times, last edit by "Neo" (Mar 31st 2010, 11:38pm)


AlexL

Junior Schreiberling

  • "AlexL" is male

Posts: 222

Date of registration: Feb 10th 2008

Location: Walsrode

Occupation: Master Informatik

2

Thursday, April 1st 2010, 7:24am

so pontan.... keine ahnung
aber es könnt ja zB sein dass jemand seinen browser auf 200% gestellt hat und wenn man dann 11.5 hohen text hat werden da 23 statt 22px draus

Gruß, Alex

Bastian

Dies, das, einfach so verschiedene Dinge

Posts: 988

Date of registration: Sep 30th 2007

3

Thursday, April 1st 2010, 9:29am

Pixel (px) sind zudem eine relative Einheit, so wie em und ex. Absolute Einheiten sind in, cm, mm, pt und pc.

Für beide gilt nach Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification - 4 Syntax and basic data types - Values:

Quoted

4.3.1 Integers and real numbers

Some value types may have integer values (denoted by <integer>) or real number values (denoted by <number>).

Quoted

4.3.2 Lengths

...

The format of a length value (denoted by <length> in this specification) is a <number> (with or without a decimal point) immediately followed by a unit identifier (e.g., px, em, etc.).

This post has been edited 2 times, last edit by "Bastian" (Apr 1st 2010, 9:42am)


KaiStapel

Trainee

Posts: 59

Date of registration: Sep 11th 2007

Location: FG SE, LUH

4

Thursday, April 1st 2010, 10:08am

Folgendes habe ich mal machen müssen, weil Firefox 3.0.x leicht anders rundet als alle anderen Browser:

Source code

1
2
3
4
5
6
7
#bg {
    margin: 0 0 0 0.5px; /* the 0.5px left margin fixes the FF 3.0.x rounding problem with centered background images */ 
    padding: 0;
    background-image: url(background.jpg);
    background-repeat: no-repeat;
    background-position: center top;
}


Gruß,
Kai
© by Kai

  • "Schokoholic" is male

Posts: 2,518

Date of registration: Oct 4th 2006

Location: Hannover

Occupation: Haarspaltung

5

Thursday, April 1st 2010, 11:20am

Folgendes habe ich mal machen müssen, weil Firefox 3.0.x leicht anders rundet als alle anderen Browser:

Meinst du das hier?



Das passiert bei mir im Opera 10.51 wenn die Breite der Seite in Pixel entweder gerade oder ungerade ist (eins von beiden, wollte jetzt nicht nachzählen welches...). Im anderen Fall siehts gut aus.

KaiStapel

Trainee

Posts: 59

Date of registration: Sep 11th 2007

Location: FG SE, LUH

6

Thursday, April 1st 2010, 3:00pm

Ja, genau das ist das Problem. Wie es aussieht habe ich es nicht wirklich gelöst bekommen ;)

Kai
© by Kai