I know this looks very simple, but I have been trying to figure out a solution for an hour now. I have an "a" element with text and an image inside. The problem is that the image goes below the text, and I want them lined up.
a {
text-decoration: none;
color: #fff;
}
a:hover {
color: #ff5c33;
text-decoration: none;
cursor: pointer;
}
#nav-user-logo{
max-height: 16px;
}
<!-- Header right part -->
<div class="dropdown">
<a>
User123
<img src="Images/Icons/user.svg" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content" >
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
I didn't have the issue myself but you can do
#nav-user-logo {
max-height: 1em;
display: inline;
}
to guarantee it is inline with the text.
By defect, any browser, with your css will display the image side by side as, I think, you want:
example with your code:
a {
text-decoration: none;
}
a:hover {
color: #ff5c33;
text-decoration: none;
cursor: pointer;
}
#nav-user-logo{
max-height: 16px;
}
<div class="dropdown">
<a>
User123
<img src="https://www.ajvs.com/redirect/5/Agilent_IMG300_UHV_R0343301_1,8926cf9ec9ce009a52f3ea8866b07f5f" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content">
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
Probably, you have some kind of "reset" css sheet that is turning all your images as display:block It's quite common in many wordpress themes. You may need to overwrite these css adding img {display:inline-block} or similar rule. Calling to the id image or class to not break your whole theme.
Turns out the issue was something super simple. This code is in a header, on the right side, and the "a" element was too small to display the code and image side by side. I fixed it with the following:
<!-- Header right part -->
<div class="dropdown">
<a style="display:inline-block; width: 150px;">
User123
<img src="Images/Icons/user.svg" id="nav-user-logo" alt='User123'>
</a>
<div class="dropdown-content user-dropdown-content" >
<a>AW Admin</a>
<a>Account Settings</a>
<a>Change Password</a>
<a>Logout</a>
</div>
</div>
Related
there were so many questions about that but none of them are helpful for me. I want normal links blue and underlined while the titles for articles should be red and without underline. This is the code:
a {
color: #337ab7;
text-decoration: underline;
}
.field.field--name-title{
color: #fffff0;
text-decoration: none;
}
I tried combine like: a.field.field--name-title and .field.field--name-title a but it doesn't work.
#EDIT
Adding HTML, this is the DIV with the article:
<div class="views-row">
<article role="article" about="/de/link-test" class="node node--type-blog-entry node--promoted node--view-mode-teaser clearfix">
<div class="node__container">
<div class="node__main-content clearfix">
<header class="node__header">
<h2 class="node__title">
<a href="/de/link-test" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">LINK TEST</span>
</a>
</h2>
</header>
<div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>tu jest link www.example.com</p>
</div>
<div class="node__links">
<ul class="links inline"><li class="node-readmore">Weiterlesen<span class="visually-hidden"> über LINK TEST</span></li></ul> </div>
</div>
</div>
</article>
</div>
You are targeting the wrong selector. .field.field--name-title is the span inside the anchor tag. Given the markup you provided, try this:
a {
color: #337ab7;
text-decoration: underline;
}
.node__title a {
color: #fffff0;
text-decoration: none;
}
Better still would be to give the anchor tag a class and target that.
If the link (i.e. a tag) does not have the .field.field--name-title classes itself, but is inside those elements, you'd have to write
.field.field--name-title a {
color: #fffff0;
text-decoration: none;
}
That would be the case if the HTML is for example
<li class="field field--name-title">
Title
</li>
If this doesn't apply, you really should post the relevant HTML code, even if you can't edit it, since we have to see the HTML structure in order to get the correct CSS selectors...
ADDITION AFTER HTML CODE HAVING BEEN ADDED:
In this case the selector should be
a.field.field--name-title
If that doesn't work, there might already be a rule with higher specifity in the CSS of your site, so you can extend it to
a.field.field--name-title.field--type-string.field--label-hidden { ... }
And if that still isn't enough, you can add some more, like
.node__container .node__main-content .node__header a.field.field--name-title.field--type-string.field--label-hidden { ... }
a {
color: #337ab7;
text-decoration: none;
}
.node__title a {
color: #fffff0;
text-decoration: none;
}
<div class="views-row">
<article role="article" about="/de/link-test" class="node node--type-blog-entry node--promoted node--view-mode-teaser clearfix">
<div class="node__container">
<div class="node__main-content clearfix">
<header class="node__header">
<h2 class="node__title">
<a href="/de/link-test" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">LINK TEST</span>
</a>
</h2>
</header>
<div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>tu jest link www.example.com</p>
</div>
<div class="node__links">
<ul class="links inline"><li class="node-readmore">Weiterlesen<span class="visually-hidden"> über LINK TEST</span></li></ul> </div>
</div>
</div>
I have made a list with bootstrap and I would like to change the background-color of each item. I have this:
.list-group {
background-color: black;
}
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">
<picture>
<img class="imagenLista" src="myimage">
</picture>
<p>
<br>sometext
</p>
</a>
</div>
I am using chromium and firefox and I have the same problem, but the curious thing is that in JSBin, it works. I am using sublime text(I don't know if it is important) also.
You should target list-group-item not list-group
Here's a working example (with bootstrap imported)
Please add your css to list-group-item
.list-group{
background-color: black;
}
a.list-group-item.list-group-item-action {
background-color: #000;
}
Maybe it's a bug, I'm not sure, but when using the mobile collapse menu, the icons and the text are not aligned (see images).
The reason is because of these CSS properties:
HTML:
.side-nav a {
color: #444;
display: block;
font-size: 1rem;
height: 64px;
line-height: 64px;
padding: 0 30px;
}
nav i.material-icons {
display: block;
font-size: 2rem;
height: 56px;
line-height: 56px;
}
<ul style="transform: translateX(0px);" class="side-nav" id="mobile-menu">
<img src="images/costum_logos/logo3.png" class="custom-logo">
<div class="divider"></div>
<a href="index.php" class="waves-effect waves-light">Albums
<i class="material-icons left notranslate">collections</i>
</a>
<a href="?page=settings" class="waves-effect waves-light">Settings
<i class="material-icons left notranslate">settings</i></a>
<a class="waves-effect waves-light red-text text-lighten-1" href="index.php?logout">Logout
<i class="material-icons left notranslate">power_settings_new</i>
</a>
</ul>
Of course, the interesting bits are the line-height and height properties on both the anchor tag, and the icon tag. They are not equal. If I override either one of them, to be exactly like the other - they are perfectly aligned.
My question is: Am I doing something wrong? I can easily get around it, but I want to have a good practice with materialize CSS. Don't wanna hack around and break their conventions.
Thanks in advance!
I want to have the same size for 3 containers defined as follows:
<div class="workingItemContainer">
<div id="workingItemContainer" runat="server">
<a class="workingItem" runat="server" id="workingQuoteAnchor">
<%=quoteNumberAnchor%>
</a>
<br />
<a class="workingItem" runat="server" id="workingPOMAnchor">
<%=pomNumberAnchor%>
</a>
<a class="workingItem" runat="server" id="workingProdCancelAnchor">
<%=prodCancelNumberAnchor%>
</a>
</div>
</div>
This is the code the code in css that implements the background and the font:
.workingItemContainer {
text-align: center;
}
.workingItemContainer div {
display: inline-block;
background-color: #ff9900;
}
If I display the workingQuoteAnchor, it shows differently from the others.
Maybe try removing the <br> tag that is after the #workingQuoteAnchor . That is most probably creating the extra space. Also if you need any spaces do that using CSS instead of changing the DOM for such cosmetic purpose.
I added : max-width in
.workingItemContainer div {
display: inline-block;
background-color: #ff9900;
}
and solved the problem.
A few days ago I was working on a classic menu. It has a logo on the left and some menu buttons on the right. This was my first try – fiddle1. But someone from this community told me that menus normally aren't coded like that but with <ul>and <li>.
So I tried to rebuild that menu – fiddle2. Unfortunately nothing works.
My first issue is that I have the feeling that the <div id="menubuttons"> is not located IN the <div id="header">. The second problem is that <div id="menubuttons" align="right"> isn't aligned right as it should be.
Can you help me to get the visual result of fiddle1 with <ul>and <li> tags?
ul element by default will take margin
So please add css like this, it will remove the default margin and padding
ul{margin:0; padding:0}
#menubuttons { float:right}
Check this Demo
I changed some code, try this:
http://jsfiddle.net/WnneG/
<ul style="float:left;paddin:0px;margin:0px;">
<li class="menubutton"> Home
</li >
<li class="menubutton"> Info
</li>
<li class="menubutton"> Spenden
</li >
<li class="menubutton" align="right" style="margin-right: 20px;"> Kontakt & Impressum
</li >
</ul>
replace this line of code:
<div id="header_logo" align="left">
<img src="http://futurized.t15.org/fut_logo.png" style="height: 12px; z-index: 2;" />
</div>
<div id="header_menu" align="right">
with:
<div id="header_logo" style="float:left;">
<img src="http://futurized.t15.org/fut_logo.png" style="height: 12px; z-index: 2;" />
</div>
<div id="header_menu" style="float:right;">
hopefully you will get your desired result if this help You please mark it as green
See the code in the fiddles you posted. Yours tries to create a menu from divs, while the one you are trying to get to, has <li> items with float: left;
Put to <li> tag style display:block;float:right; like this: <li style="display:block;float:right">
Use float = right instead of align for the div menubuttons.
#menubuttons {
margin-right: 0;
margin-top: 0;
height: 2.5em;
line-height: 2.5em;
display: block;
float:right;
}
I have created a version of your menu. I think this helps: http://jsfiddle.net/yBTJF/4/
.menu
{
height: 30px;
background: #FFFFFF;
line-height: 30px;
list-style: none;
padding: 0 5px;
margin: 0px;
}
If you want :hover, all you have to do is create a selector in your CSS:
.menu a:hover
{
// ...
}