Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple text alignment on button issue

Featured Replies

I have a really silly problem which is annoying and wondered if anyone could help.

 

I am currently working on this web site: http://www.lucky-magpies.co.uk/lifestyle/ and as you can see, the text on the buttons on the left hand side don't look quite right. I want the text such as 'Home' to be centralized (between top and bottom) but I cannot find away to do this as it messes up the text which is on 2 lines such as 'Personal Training and Group Exercise'

 

Anyone know of a way I can have a custom align for each of the buttons, rather than applying a style to all? Or perhaps a different way althogether, feel free to look a source code, or I can post it if needed.

 

Many thanks,

 

Sophie

Say the div is 100px tall. You set the line-height the same. This the vertically aligns the text.

 

Quick bit of CSS to demonstrate:

 

.myDiv { width: 100px; height: 100px; line-height: 100px; }

 

Simples!

  • Author

Say the div is 100px tall. You set the line-height the same. This the vertically aligns the text.

 

Quick bit of CSS to demonstrate:

 

.myDiv { width: 100px; height: 100px; line-height: 100px; }

 

Simples!

 

 

Thanks very much for that, I think there is an issue with the fact some of the text is on 2 lines though. When I put the line height the same as the block height like you mention, the second half of the text disappears. Anyway you think I can rectify this?

Yeh you'll want to use padding instead. To get it uniform you may want to apply a different method of making your buttons.

 

Maybe progressively enhance to achieve your gradients.

 

Lost the gradients and rounded corners altogether.

 

Create a lot of mark up and images and do it the old fashioned way.

 

Use a sprite with all those images and create a lot of markup.

 

The markup would be something like this.

 

<ul>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>
</ul>

 

CSS

 

li { position: relative; width: width of your button; text-align: center; padding: 10px 5px; background-image: gradient; background-repeat: repeat-x; background-color: #match the bottom colour from your gradient; }

span { position: absolute; }
.top-left { top: 0; left: 0; height: 5px; width: 5px; background-image: url(top-corner.png); }
.top-right { top: 0; right: 0; height: 5px; width: 5px; background-image: url(top-corner.png); }
.btm-left { bottom: 0; left: 0; height: 5px; width: 5px; background-image: url(bottom-corner.png); }
.btm-right{ bottom: 0; right: 0; height: 5px; width: 5px; background-image: url(bottom-corner.png); }

 

If you Google "Sampson video tutorials" you will find a tidy video tutorial somewhere on this technique.

  • Author

Yeh you'll want to use padding instead. To get it uniform you may want to apply a different method of making your buttons.

 

Maybe progressively enhance to achieve your gradients.

 

Lost the gradients and rounded corners altogether.

 

Create a lot of mark up and images and do it the old fashioned way.

 

Use a sprite with all those images and create a lot of markup.

 

The markup would be something like this.

 

<ul>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>

	<li>
         <span class="top-left"></span>
         <span class="top-right"></span>
         <a href="#">This will be a link, probably wrapping two or three lines.</a>
         <span class="btm-left"></span>
         <span class="btm-left"></span>
	</li>
</ul>

 

CSS

 

li { position: relative; width: width of your button; text-align: center; padding: 10px 5px; background-image: gradient; background-repeat: repeat-x; background-color: #match the bottom colour from your gradient; }

span { position: absolute; }
.top-left { top: 0; left: 0; height: 5px; width: 5px; background-image: url(top-corner.png); }
.top-right { top: 0; right: 0; height: 5px; width: 5px; background-image: url(top-corner.png); }
.btm-left { bottom: 0; left: 0; height: 5px; width: 5px; background-image: url(bottom-corner.png); }
.btm-right{ bottom: 0; right: 0; height: 5px; width: 5px; background-image: url(bottom-corner.png); }

 

If you Google "Sampson video tutorials" you will find a tidy video tutorial somewhere on this technique.

 

O.K I was being a little lazy avoiding the 'old fashioned way' but will give it a go now, thanks so much for you're help :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.