Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set the width of a roundrect to its content width?

Tags:

vml

I am building a button, using vml because it's the only way to make it rounded on Outlook emails. I need its width to depend on its content. However I can't find a way to do so. The only width I am able to give it is a fixed width.

<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"
     style="width:200px; height:41px; v-text-anchor:middle;"
     arcsize="10%"
     stroke="f"
     fillcolor="#d62828">
  <w:anchorlock/>
  <center style="color:#ffffff;font-family:sans-serif;font-size:16px;font-weight:bold;">
    Découvrir
  </center>
</v:roundrect>

Is it possible to make its width depend on its content width? And if not, is it possible to make it equal to 100% of its parent (I tried mso-width-percent but it depends on the viewport width, not the parent width)?

like image 343
papillon Avatar asked Oct 29 '25 08:10

papillon


1 Answers

I know this is old, but in case someone is still trying to figure this out, I was able to get the <v:roundrect> to expand to the size of the text with the following:

style="mso-wrap-style:none; mso-fit-shape-to-text: true;"

The problem was that it was wrapping on words causing it to look like it wasn't expanding correctly. This resolves that.

like image 85
Jim Hulbert Avatar answered Oct 31 '25 11:10

Jim Hulbert