I am building a custom bootstrap 3 theme. I have created a new widget area for my header and am trying to get the widgets there to display horizontally, in line. I’ve looked up several tutorials, but none seem to be working. Can anyone help?
**Here is my CSS for the list:**
#top-widget-container ul {
list-style-type: none;
}
#top-widget-container ul li {
display: inline;
}
**And my functions.php widget insert**
add_action( 'widgets_init', 'add_header_widget' );
function add_header_widget() {
register_sidebar( array(
'name' => 'Header Widget Area',
'id' => 'header_widget',
'before_widget' => '<li id="top-widget-container ul li">',
'after_widget' => '</li>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
You’re looking for either
float
orinline-block
. For a variety of reasons, I preferinline-block
:Notice that I’ve used the “direct descendant” selector (aka child combinator selector or immediate child):
ul > li
– that way, any sub-lists don’t get this same formatting (which could cause all sorts of challenges). This selector is supported in modern browsers, IE8+, and IE7 (usually).Alternatively, the float technique (don’t like it as well, but will work):