As you can see, the ours are not completely aligned.
see where?
can you provide a live link to your site, to a post or page with the problem?
what theme are you using?
http://codex.wordpress.org/Forum_Welcome#Include_as_much_information_as_possible
Thread Starter
Sauron
(@sauron)
I tried to make the example in my post, but i see that even this forum messes up my spaces….:)
Anyway, here is an example if you go to the section opening hours:
http://www.whalesafari.no/en/restaurant
This is not the worst example, but i guess it still makes the point.
I am using the Omni theme.
You can try this.
Go to that post/page and use the text editor rather than the visual editor. Add this just before the list of hours:
<div style="text-align: right; width: 45%;">
Immediately after the list of hours, add this:
</div>
You could also add the div with a class like this:
<div class="open-hours">
Then add the CSS using a child theme or a CSS plugin.
.open-hours {
width: 45%;
text-align: right;
}
If you want to create space between the day and the hours, you can wrap the hours in a span:
<div class="open-hours">
Monday <span>20:00 to 22:00</span>
Monday <span>20:00 to 22:00</span>
</div>
Then you can style the span:
.open-hours span{
padding-left: 12px;
}
It looks more complicated than it is.
If you want it to work responsively then you are going to need to think what you break points are and change or remove the width on the div accordingly.
Thread Starter
Sauron
(@sauron)
Hi,
Tried the last method but got the following result:
http://www.whalesafari.no/restaurant
As you can see the whole list is shifted to the right and aligned. If i change the text-align attribute to left instead of right, I get the same result as I had originally. Ideas? 🙂
HTML
<div class="open-hours">
<p>Mandager<span>12:00 - 20:00</span></p>
<p>Tirsdager<span>12:00 - 22:00</span></p>
<p>Onsdager<span>12:00 - 22:00</span></p>
<p>Torsdager<span>12:00 - 22:00</span></p>
<p>Fredager<span>12:00 - 22:00</span></p>
<p>Lørdager<span>11:00 - 22:00</span></p>
<p>Søndager<span>12:00 - 20:00</span></p></div>
No br or non-breeaking spaces
CSS
.open-hours span {
display: inline-block;
float: right;
text-align: right;
width: 106px;
}
.open-hours p {
line-height: 1.4;
margin: 0;
padding: 0;
}
.open-hours {
display: table;
margin-bottom: 18px;
}
You could also indent it a little by adding:
margin-left: 24px;
To the .open-hours rule.
Thread Starter
Sauron
(@sauron)
Hmmm…
Got this now:
http://www.whalesafari.no/restaurant
Can it be that something else is overriding this code? Copied and pasted your code, so it should be correct. Amazing that it is so hard to just get some basic tab functionality…:) Did the inventors forget it? 😉
The HTML does not appear to have the span element inside the p element
.open-hours span {
display: inline-block;
float: right;
text-align: right;
width: 106px;
margin-left: 16px;
}
And I forgot margin-left in that rule. You can change the value as you see fit.
Thread Starter
Sauron
(@sauron)
Worked well!! 🙂
I was planning to use a table for this but i got into a lot of problems since i did not manage to:
1) Make a table that didn’t use the whole with of the section.
2) Make the cell borders invisible.
Do you think that is due to a kind of “global” setting somewhere?
If you check this page:
http://www.whalesafari.no/en/departures
you can see that i managed to make some tables with a shortcake plugin. How to change colors and the with of the table is a big question since it seems that all tables I make end up in that size anyway…
Maybe I should read some basic HTML and CSS….;)
Anyway, thanks a lot for solving my “tab” problem!
Thread Starter
Sauron
(@sauron)
by the way…dont know where “shortcake” came from…was supposed to be shortcode…:D
I’m glad you got it sorted.
As for “global” settings, it is likely that your them has some CSS for most elements. However, it is likely that with CSS, you can add your own styles.
I think the best way to edit a theme is to use a child theme.
I looked at your tables and they seemed good to me. Well done.
It won’t hurt to read about HTML/CSS.
Maybe you could mark this thread “resolved.”
Thread Starter
Sauron
(@sauron)
Will do…and again, thanks!