I have this menu bar, which is replaced by Images.
All looks good on normal view, but when I swtich to mobile view
It looks so clumsy. I tried Padding, But the individual cell do not
make up space with each other.
Here is the screenshot
li.topmenu1 {
height: 20px;
}
<nav id="category" class="drawer_block pc">
<ul class="category-nav">
<li class="topmenu1">
<img src="http://azlily.bex.jp/eccube_1/html/template/default/img/menu/home.png">
</li>
<li class="topmenu2">
<img src="/eccube_1/html/template/default/img/menu/products.png">
</li>
<li class="topmenu3">
<img src="/eccube_1/html/template/default/img/menu/about.png">
</li>
<li class="topmenu4">
<img src="/eccube_1/html/template/default/img/menu/howtouse.png">
</li>
<li class="topmenu5">
<img src="/eccube_1/html/template/default/img/menu/column.png">
</li>
<li class="topmenu8">
<img src="/eccube_1/html/template/default/img/menu/FAQ.png">
</li>
</ul>
</nav>
Note - I also tried to include FULL URL of the image
but somehow its not showing up on snippets :/
check this https://jsfiddle.net/1dvy2854/4/
.category-nav li {
display: inline-block;
}
#media only screen and (max-width: 600px) {
.category-nav li {
display: block;
}
.category-nav li img {
max-width: 65px;
display: inline-block;
}}
Make sure that the elements inside category-nav have correct margins and paddings.
If you want to make sure that the individual pictures for the menu look okay, you might want to set styles for the images one by one.
So, in your case you can edit the heights for all of your topmenu1, topmenu2...
Also, you can the inspect tool on Chrome to find what is causing problems like this in your CSS code. You can change the code live and see what change is causing what.
Related
I'm making a responsive website. At the bottom I have a phone icon, a phone number, a mail icon and a mail address – all in one line.
<img src="https://cdn.pixabay.com/photo/2013/07/13/10/30/icon-157358_960_720.png" height="150px" width="111px">
123456
<img src="https://cdn.pixabay.com/photo/2016/06/13/17/30/mail-1454734_960_720.png" height="150px" width="150px">
asdf#gmail.com
In full window, it looks like this:
[phone img][phone number] [mail img][mail address]
When I resize the window they end up like this:
[phone img][phone number][mail img]
[mail address]
I want the icons and texts to stick together, like this:
[phone img][phone number]
[mail img][mail address]
I tried encasing them with div and span, but none worked. I also googled "html two elements stick together" without result. It feels really basic and I feel quite stupid, but I can't figure this out.
How about this:
<a href="tel:123456">
<img src="phone.jpg">123456
</a>
<a href="mailto:asdf#gmail.com">
<img src="mail.jpg">asdf#gmail.com</a>
use css to add paddings and responsive behaviours
What you could do is make both elements part of an unordered list and display that as two separate blocks on mobile. When the viewport grows (#media screen and (min-width: 600px)), the list elements (<li>) will display next to each other, thanks to display: inline-block;.
ul {
list-style: none;
}
#media screen and (min-width: 600px) {
li {
display: inline-block;
padding: 0 10px;
}
<ul>
<li><img src="phone.jpg">
123456</li>
<li><img src="mail.jpg">
asdf#gmail.com</li>
</ul>
I'm trying to resolve a mystery. On chrome everything is good but in Safari when I hoover some element (circled in red) they are moving a bit.
This is only happening on the first hoover. The second time you do it nothing happens.
I tried to reproduce the situation here :
<nav class="cd-secondary-nav">
<ul class="has-magic-line">
<li id="all-events" class="active"><a>Tous</a></li>
<li id="week-events" class=""><a>Semaine</a></li>
<li id="weekend-events" class=""><a>Week-end</a></li>
<li id="recent-events" class="" style="position: relative;"><a>Nouveaux</a></li>
<li class="magic-line" style="transform: translateX(103.844px) scaleX(73.75);"></li>
</ul>
</nav>
https://jsfiddle.net/ykgjsfrh/1/ but it does work well even in Safari ...
Thank you for your help
Have you tried adding this to the li inside the nav in your css file:
li {
height: 100%;
text-align: center;
width: 100%;
}
I wasn't able to fully test this with a fresh reload in the browser. It looked like the problem might have been that the size of each <li> was different after you hovered the links in Safari, but I can be wrong.
I met the same issue, and it does need to put the height:100% in the style. But, we should put the height:100% into ul not li in this case.
I've managed to put a great looking menu togheter!`
<li class="huvudmenu">Framsida</li>
<li class="huvudmenu">
<a>Om oss</a>
<ul>
<li>Styrelsen</li>
<li>Historik</li>
<li>Stadgar</li>
<li>Topeliuspriset</li>
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
</ul>
</li>
<li class="huvudmenu">Verksamhet
<ul>
<li>Hangö seminariet</li>
<li>Årsberättelser</li>
</ul>
</li>
<li class="huvudmenu">Estholmen</li>
<li class="huvudmenu">Bli medlem</li>
`http://jsfiddle.net/hx6uvc19/ The setup I have does not, unfortunatley, work very well on touch screen devices. Is there any way I can keep the design while making it touch screen compatible?
Thanks!
You can not use the :hover pseudo class on mobile. In order to get this effect you can use JQuery as stated by #jbutler483 in the comments.
If you wanted to do this you could do it by adding an .active class to the main li's (By using the class .huvudmenu) on click/touchstart and add this to the css where you have your hover styles as well.
This is the JQuery:
$('.huvudmenu').on('click touchstart', function(e){
e.preventDefault();
$(this).toggleClass('active').siblings().removeClass('active');
});
and the styles to add are:
nav ul li.active > ul {
display: block;
}
and
nav ul li.active:after {
width: 100%;
background: #404040;
}
this will then allow the styles on click and touchstart events. If you wanted this to only run on mobile you could just remove the click and use touchstart events and/or put some kind of detection that this is a mobile device before initialising the JQuery function.
Here is an update to your fiddle: http://jsfiddle.net/lee_gladding/hx6uvc19/3/
I am using JQM 1.4.2 and trying to get the button icons closer to the Text when using the class .ui-btn-icon-left.
I took a screen shot and modified the the list icon the way I want it to look in the middle button. I just cant seem to get the icon off the left side at all. using padding just changed the top and bottom.
What class do I need to use to accomplish this?
<div data-role="navbar" >
<ul id="navfooter">
<li>Tour</li>
<li><a class="ui-nodisc-icon ui-icon-bars ui-btn-icon-left svbtn" href="#listViewPage" data-transition="slide" >List</a></li>
<li><a class="ui-nodisc-icon ui-icon-location ui-btn-icon-left svbtn" href="#map-page" data-transition="slide" >Map</a></li>
</ul>
</div>
Here is the image of what it now looks like after adding the css
.ui-icon-home::after {
position: relative;
left:10px;
}
You can set the left position of the icons within the button:
.ui-navbar a:after {
left: 20% !important;
}
However, this will allow the icon and text to overlap as the buttons get smaller.
A better way to achieve this might be to put the icons inline with the text. You put a span in front of the text with CSS to place the icon. To control the distance between the icon and the text, tweak the margin-right attribute:
<div data-role="navbar">
<ul>
<li><span class="ui-icon-alert ui-btn-icon-notext inlineIcon"></span>Summary
</li>
<li><span class="ui-icon-star ui-btn-icon-notext inlineIcon"></span>Favs
</li>
<li><span class="ui-icon-gear ui-btn-icon-notext inlineIcon"></span>Setup
</li>
</ul>
</div>
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
If you want icons in black with no disc behind them add the ui-alt-icon class to the span and change the CSS to get rid of the disc:
<div data-role="navbar">
<ul>
<li><span class="ui-alt-icon ui-icon-alert ui-btn-icon-notext inlineIconNoDisk"></span>Summary
</li>
<li><span class="ui-alt-icon ui-icon-star ui-btn-icon-notext inlineIconNoDisk"></span>Favs
</li>
<li><span class="ui-alt-icon ui-icon-gear ui-btn-icon-notext inlineIconNoDisk"></span>Setup
</li>
</ul>
</div>
.inlineIconNoDisk {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
.inlineIconNoDisk:after {
background-color: transparent !important;
}
Here is a DEMO showing all 3 options
If it's just the home icon you're looking to move, applying the following to that icon should fix it but it's hard to say what the best solution is without seeing the menu in action.
.ui-icon-home::after {
left: (amount to shift left)px;
}
Note that ::after applies styling to just the icon, whereas ".ui-icon-home" applies to the entire anchor element. Again, if you could link to a pastebin or similar, it would be easier to give you a better answer.
<div class="actions-wrapper">
<ul>
<li>
<a class="" href="#answer-form">
<img src="images/icons/answer.gif" class="answer-icon icon"/>
</a>
<a class="" href="">
Action1
</a>
</li>
<li>
<a class="" href="">
<img src="images/icons/answer.gif" class="answer-icon icon"/>
</a>
<a class="" href="">
Action2
</a>
</li>
</ul>
</div>
Hello, I have the previous code.
My div has a max size, and i want to display the li inline, but at the end of the line, i dont want the containing the icon to be separated from its text within the same li.
In my css i have the following :
.actions-wrapper ul { line-height: 25px;padding: 0; margin:0; list-style-position: outside; list-style-type: none;display: block; }
.actions-wrapper ul li { display:inline; margin-right: 12px;padding:3px 0;}
I have tried to put : white-space: nowrap; to the li, but it doesnt work in IE.
Here's a jsfiddle of my code : http://jsfiddle.net/wSTQy/1/
In this example the "Another action" is not on the same line of its icon.
If i add the white-space : nowrap; it wont work anymore in IE6
does adding the text-alignment to the ul achieve what you want?
.actions-wrapper ul {
text-align: right;
}
Updated after new information
changing the display of the li to inline-block instead of inline (needs a hack for IE7 and below) seems to work, even without the white-space: nowrap;
Updated fiddle (with hack included) : here
By looking at your markup, seems you want the icon and the text to make the same action.
Why not use css to add the icon next to the text, like so:
<li>
<a href="#answer-form" id="icon-label">
Action1
</a>
</li>
With the CSS:
#icon-label {
background: transparent url(path/to/image) no-repeat x y;
}
You can do this by removing all the whitespace from between the anchors, and separating them with a .
I think the easiest solution would be to change display:inline to float:left. That way the icons and the text never get separated.