Note that there are some explanatory texts on larger screens.

plurals
  1. PONav menu - Rendering dividing pipe characters
    primarykey
    data
    text
    <p>I have a webcontrol with a handful of links displayed at the top, eg:</p> <pre><code>Link 1 | Link 2 | Link 3 </code></pre> <p>Currently they're each an asp:Hyperlink. <code>Is there a clever solution for rendering out the dividing pipe characters?</code></p> <p>Currently they're within the containing placeholder. We can't make any guarantees about a given link always appearing. I don't want a really big if-statement, and I'm reluctant to render all the links purely in the code-behind...</p> <p><strong>[Update]</strong></p> <p>Thanks for pointing out that CSS is the way to go. It's certainly made things easier. We did, of course, need a cross-browser solution though.</p> <p>The HTML list (<em>&lt;ul&gt;</em> &amp; <em>&lt;li&gt;</em>) structure works a treat, as the <strong>first-child</strong> / <strong>last-child</strong> properties take care of the end of the list. <em>Note</em>: These are automatic - you don't have to assign them in the markup.</p> <p>As we only needed pipe symbols, I used the border property. If you wanted, you could use the <strong>margin-left</strong> + <strong>background</strong> image CSS properties to have an image spacer instead.</p> <p>Our solution:</p> <p><em>HTML:</em></p> <pre><code>&lt;ul class="navMenu"&gt; &lt;li&gt;&lt;a href="..."&gt;Link 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="..."&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="..."&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p><em>CSS:</em></p> <pre><code>ul.navMenu li { display: inline; margin-left: 0; } ul.navMenu a { border-left: solid 1px #333333; padding-left: 0.4em; padding-right: 0.4em; } ul.navMenu li.first-child a { border-left: none 0; padding-left: 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload