Skip to content

Instantly share code, notes, and snippets.

@PrideChung
Created May 9, 2012 09:07
Show Gist options
  • Select an option

  • Save PrideChung/2643180 to your computer and use it in GitHub Desktop.

Select an option

Save PrideChung/2643180 to your computer and use it in GitHub Desktop.

Revisions

  1. PrideChung revised this gist May 10, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.html
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <style> selector{ max-width:100px; } </style>
    <!--[if IE 6]>
    <style>
    selector{ _width:expression(this.width>100?(function(dom){dom.style.width='100px';})(this):'auto'); max-width: 100px; } </style>
    selector{ _width:expression(this.width>100?(function(dom){dom.style.width='100px';})(this):'auto');} </style>
    <![endif]-->

    <!-- NOTICE: target element must NOT set width or height attribute, or this doesn't work -->
    @@ -12,7 +12,7 @@
    <content><![CDATA[
    <style> ${1:selector}{ max-width:${2:maxwidth}px; } </style>
    <!--[if IE 6]>
    <style> ${1}{ _width:expression(this.width>${2}?(function(dom){dom.style.width='${2}px';})(this):'auto'); max-width: ${2}px; } </style>
    <style> ${1}{ _width:expression(this.width>${2}?(function(dom){dom.style.width='${2}px';})(this):'auto'); } </style>
    <![endif]-->
    ]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  2. PrideChung revised this gist May 10, 2012. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion gistfile1.html
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,19 @@
    selector{ _width:expression(this.width>100?(function(dom){dom.style.width='100px';})(this):'auto'); max-width: 100px; } </style>
    <![endif]-->

    <!-- NOTICE: target element must NOT set width or height attribute, or this doesn't work -->
    <!-- NOTICE: target element must NOT set width or height attribute, or this doesn't work -->

    <!-- I made a Sublime Text snippet, maybe can also use in TextMate -->

    <snippet>
    <content><![CDATA[
    <style> ${1:selector}{ max-width:${2:maxwidth}px; } </style>
    <!--[if IE 6]>
    <style> ${1}{ _width:expression(this.width>${2}?(function(dom){dom.style.width='${2}px';})(this):'auto'); max-width: ${2}px; } </style>
    <![endif]-->
    ]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>maxwidth</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
    </snippet>
  3. PrideChung revised this gist May 9, 2012. No changes.
  4. PrideChung revised this gist May 9, 2012. 2 changed files with 7 additions and 4 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    <style> selector{ max-width:100px; } </style>
    <!--[if IE 6]>
    <style>
    selector{ _width:expression(this.width>100?(function(dom){dom.style.width='100px';})(this):'auto'); max-width: 100px; } </style>
    <![endif]-->

    <!-- NOTICE: target element must NOT set width or height attribute, or this doesn't work -->
    4 changes: 0 additions & 4 deletions max-width.html
    Original file line number Diff line number Diff line change
    @@ -1,4 +0,0 @@
    <style> selector{ max-width:maxwidthpx; } </style>
    <!--[if IE]>
    <style> selector{ _width:expression(this.width>maxwidth?(function(dom){dom.style.width='maxwidthpx';})(this):'auto'); max-width: maxwidthpx; } </style>
    <![endif]-->
  5. PrideChung created this gist May 9, 2012.
    4 changes: 4 additions & 0 deletions max-width.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <style> selector{ max-width:maxwidthpx; } </style>
    <!--[if IE]>
    <style> selector{ _width:expression(this.width>maxwidth?(function(dom){dom.style.width='maxwidthpx';})(this):'auto'); max-width: maxwidthpx; } </style>
    <![endif]-->