Category Archives: Web Design

How to stop text taking up more than one line – CSS

Hey everyone,

Just a quick post on how to stop text taking up more than one line using only CSS:

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

You can check it out using this fiddle: http://jsfiddle.net/wb5m7/
There’s also a great StackOverflow post: http://stackoverflow.com/a/572302/522859

Twitter Bootstrap Dropdown Button

Dropdown Button – Twitter Bootstrap

Hey everyone,

Just a quick post on how to create a dropdown button using Twitter Bootstrap. It’s pretty straight forward, once you’ve included all your CSS etc just add the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<div style='text-align:left;'>
	<div class="btn-group">
	  <a class="btn dropdown-toggle btn-success" data-toggle="dropdown" href="#">
	    Button Text
	    <span class="caret"></span>
	  </a>
	  <ul class="dropdown-menu">
	    <li>
	    	<a href="#">Menu Option #1</a>
	    </li>
	    <li>
	    	<a href="#">Menu Option #2</a>
	    </li>
	    <li>
	    	<a href="#">Menu Option #3</a>
	    </li>
	    <li class='divider'></li>
	    <li>
	    	<a href="#">Menu Option #4</a>
	    </li>
 
	    <li>
	    	<a href="#">Menu Option #5</a>
	    </li>
	  </ul>
	</div>
</div>

Once you save that you should see something similar to the image below:

Twitter Bootstrap Dropdown Button

A standard twitter bootstrap dropdown button.

Change list item text alignment

To change the text alignment of this list items, all you need to do is adjust the text-align style assigned to the wrapper div.

Change dropdown button color

Once again, this is fairly simple, all you need to do is switch the button type. For instance, if you were after an orange button, you can swap btn-success with btn-warning. A list of the default styles is available on the Twitter Bootstrap site.

Let me know if you have any issues.

Change Current Day Color – jQuery FullCalendar

Hey everyone,

Just a quick post on how to change a few of the styles in FullCalendar. All you need to do is add these after the default styles are loaded:

Current Day Background Color

1
2
3
.fc-today{
   background-color: blue;
}

Change Calendar Background Color

1
2
3
4
#calendar .fc-content{
	background-color: #FFFFFF;
	font-size: 80%;
}

Add Box Shadow to Events

1
2
3
#calendar .fc-event{
	box-shadow: 2px 2px 2px #706868;
}

Style Times and Days – Add border radius to headings

1
2
3
4
5
6
7
#calendar .fc-agenda-axis, #calendar .fc-widget-header{
	background-color: #C2E6FF;
	border-color: #AED0EA;
	font-weight: normal;
	padding: 3px;
	border-radius: 3px;
}

Placing Multiple Button_To on the Same Line – Ruby on Rails

This is a problem that had me confused for an embarrassingly long time. Rails wraps button_to elements within a form and a div. Unfortunately this will take up 100% of the available width. Thankfully the solution is pretty straight forward – simply wrap buttons in a div and float them left like so:

1
2
3
4
5
6
    <div style="float:left;">
      <%= f.submit 'Place Order', :class => 'button'%>
    </div>
    <div style="float:left;">
      <%= button_to 'Cancel', :root, :class => 'button' %>
    </div>

A wrapper div isn’t strictly necessary however I usually add one just to be safe. While this will probably give a bunch of designers another reason to hate developers, I find that wrapping floated elements seems to save a lot of headaches when making changes down the track.

Using the code above you may also find that the divs aren’t filling as expected, simply add a div with a ‘clear:both’ style to the bottom of the wrapper:

1
2
3
4
5
6
7
8
9
10
<div>
    <div style="float:left;">
      <%= f.submit 'Place Order', :class => 'button'%>
    </div>
    <div style="float:left;">
      <%= button_to 'Cancel', :root, :class => 'button' %>
    </div>
    <div style="clear:both;">
    </div>
</div>

Hopefully that doesn’t take anywhere near as long for you guys to figure out as it did me, time for a coffee break I think. Good luck!