<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>31241</bug_id>
          
          <creation_ts>2009-11-08 10:38:18 -0800</creation_ts>
          <short_desc>Absolutely positioned, inline elements within a container that horizontally centers</short_desc>
          <delta_ts>2023-07-25 15:18:02 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>4860</dependson>
    
    <dependson>77754</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter>samail91</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>karthikeyan.jambulingam</cc>
    
    <cc>robert</cc>
    
    <cc>robin</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>161426</commentid>
    <comment_count>0</comment_count>
      <attachid>42715</attachid>
    <who name="">samail91</who>
    <bug_when>2009-11-08 10:38:18 -0800</bug_when>
    <thetext>Created attachment 42715
Reveals a rendering bug in webkit. Absolutely position, inline elements should remain centered until left or right properties are set.

Whenever an an inline element&apos;s position property is set to absolute and the left, right, top and bottom properties are left to their defaults(auto), and the parent element has text-align property set to center, the element does not keep it&apos;s position.

CSS:
#element {
position: absolute;
}
#parent {
text-align: center;
width: 500px;
height: 300px;
}

HTML:
&lt;div id=&quot;parent&quot;&gt;
&lt;span id=&quot;element&quot;&gt;Test&lt;/span&gt;
&lt;/div&gt;

The span should remain centered within it&apos;s parent until the left or right properties are explicitly set. However, if we add an inline element or text before the span:

&lt;div id=&quot;parent&quot;&gt;
Text or &amp;nbsp; or &lt;span&gt;some other inline element&lt;/span&gt;&lt;span id=&quot;element&quot;&gt;Test&lt;/span&gt;
&lt;/div&gt;

The element centers along with the elements/text before it.

I&apos;ve attached an example that shows the unexpected behavior that occurs if the position property was set to absolute via javascript.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>228389</commentid>
    <comment_count>1</comment_count>
    <who name="Shamil Kerimov">genetiq</who>
    <bug_when>2010-05-20 08:30:22 -0700</bug_when>
    <thetext>I can also confirm this bug in latest WebKit nightly build (r59821)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>326599</commentid>
    <comment_count>2</comment_count>
    <who name="">karthikeyan.jambulingam</who>
    <bug_when>2010-12-24 06:25:20 -0800</bug_when>
    <thetext>The bug is still alive in Chrome 8.0 build , is there any work around other than adding a text or &amp;nbsp; to make it work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>445999</commentid>
    <comment_count>3</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-08-03 12:18:21 -0700</bug_when>
    <thetext>I haven&apos;t confirmed the test case against the patch there but I think this is related to 4860.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>565004</commentid>
    <comment_count>4</comment_count>
    <who name="Robin Whittleton">robin</who>
    <bug_when>2012-02-25 12:26:09 -0800</bug_when>
    <thetext>The most minimal testcase I can make is:

&lt;!DOCTYPE html&gt;
&lt;style&gt;
body { text-align: center; }
span { position: absolute; }
&lt;/style&gt;
&lt;span&gt;Test</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>867080</commentid>
    <comment_count>5</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2013-04-01 05:54:51 -0700</bug_when>
    <thetext>I don&apos;t think there&apos;s anything to fix here anymore. Would you mind confirming?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1967989</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-07-25 01:48:05 -0700</bug_when>
    <thetext>I am unable to reproduce this bug in Safari 16.6 using attached test case and one from Comment 04 and it matches Chrome Canary 117.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>42715</attachid>
            <date>2009-11-08 10:38:18 -0800</date>
            <delta_ts>2009-11-08 10:38:18 -0800</delta_ts>
            <desc>Reveals a rendering bug in webkit. Absolutely position, inline elements should remain centered until left or right properties are set.</desc>
            <filename>absolutepositioninline.htm</filename>
            <type>text/html</type>
            <size>1639</size>
            <attacher>samail91</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiINCiJodHRwOi8vd3d3LnczLm9yZy9UUi94aHRtbDEvRFREL3hodG1sMS10cmFuc2l0aW9u
YWwuZHRkIj4NCjxodG1sPg0KPGhlYWQ+DQo8dGl0bGU+QWJzb2x1dGVseSBwb3NpdGlvbmVkIGlu
bGluZSBlbGVtZW50PC90aXRsZT4NCjxzdHlsZT4NCnNwYW4gew0KYmFja2dyb3VuZDogcmVkOw0K
fQ0KaW5wdXRbdHlwZT0ndGV4dCddIHsNCmJvcmRlcjogMXB4IHNvbGlkICNkZWRlZGU7DQpwYWRk
aW5nOiAzcHggM3B4IDNweCAxMTBweDsNCm1hcmdpbjogMXB4Ow0Kd2lkdGg6IDMwMHB4Ow0KfQ0K
bGFiZWwgew0KcG9zaXRpb246IGFic29sdXRlOw0KYmFja2dyb3VuZDogYmx1ZTsNCmNvbG9yOiB3
aGl0ZTsNCnBhZGRpbmc6IDBweDsNCm1hcmdpb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