How to target and hide a title with css - html

I'm trying to target a title, which is also a title. The word I want to hide is contact from the following html. There doesn't seem to be another way as even the ID is linked to the main menu so hiding it by ID would hide whole menu.
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul id="menu" class="menu">
<li id="menu-item-3530" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-3530 dropdown">
<a title="Contact" href="https://4309.co.uk/contact/">Contact</a>
<ul role="menu" class="dropdown-menu"></ul>
</li>
</ul>
</div>
Perhaps I have explained this poorly. If you look in mobile in the top left cornerhere, drop the drop down menu by toggling the hamburger icon, you will see three letters act, the end of the word contact how to get rid of that? In desktop the whole word appears below the logo. It's an item with children, and I've tried using higher tier selectors and applying them to the ID, such as ul li, but this doesn't work. Hiding the ID will hide the parent and the children, when I need to separate it from its children and hide it individually.

There are some clever ways to hide text using CSS, although that's not the most ideal approach. This approach uses a clever combination of text indentation to achieve the end result. You could use the attribute selector to target any <a> tags where the title attribute is "Contact" as such:
a[title='Contact'] {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
As referenced in this post, which can offer some more ideas as well. Notably:
a[title='Contact'] { color: transparent; }

First of all you need to target the a element which has a title of Contact. In CSS, this can be done with the following selector:
a[title="Contact"]
Then, you need to hide the element. There are two options for doing this:
display: none;
visibility: hidden;
Here is a code snippet which demonstrates the first of these two methods (using the display property):
a[title="Contact"] {
display: none;
}
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul id="menu" class="menu">
<li id="menu-item-3530" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-3530 dropdown">
<a title="Contact" href="https://4309.co.uk/contact/">Contact</a>
<ul role="menu" class="dropdown-menu"></ul>
</li>
</ul>
</div>
The bullet point is still there, so you can see that only the text Contact is being hidden, and not the li element. The CSS has targeted only the one element with that specific title.

Okay I checked, the "contact" you're talking about is under a span tag and it's on a different base level, so Imma answer your question on a conceptual basis:
So in order to hide that contact from that dropdown menu, all you'd have to do is change that element's color to the background color so it's invisible and stop the link from working using like no hover effects and removing the link from CSS using a media query of course so that it doesn't affect when browsed from other devices than mobile here's how to do it
link.href = '';
leave it blank and you are all set, It won't show you that link anymore or none can click when using mobile
As per your question now:
you are seeing the "act" instead of "contact" because of no margin when in mobile view, so fix the margin first and then if you have access to the mainframe code,
use the methods I said above and it would work I promise

Related

How to apply different margins on two types of links using BEM?

I have a nav block. This nav block contains two different kinds of links. Local links and Social links. The local links need a margin-bottom while the social links need a margin-right.
To apply the margins, would I have to add modifiers on the links? If so, what would be the best name for these two modifiers?
.nav__item--locals {
margin-bottom: 10px;
}
.nav__item--socials {
margin-right: 20px;
}
<nav class="nav">
<ul class="nav__locals">
<li class="nav__item--locals"></li>
<li class="nav__item--locals"></li>
<li class="nav__item--locals"></li>
<li class="nav__item--locals"></li>
</ul>
<ul class="nav__socials">
<li class="nav__item--socials"></li>
<li class="nav__item--socials"></li>
<li class="nav__item--socials"></li>
</ul>
</nav>
As of,
CSS Tricks AND
BEM's Website (mainly)
From Key-Val Modifiers,
Used when the modifier value is important. For example, "a menu with the islands design theme": menu_theme_islands.
The structure of the modifier's full name follows the pattern:
block-name_modifier-name_modifier-value
block-name__element-name_modifier-name_modifier-value
So, I think You should use this type of name,
.nav__item_lnk-type_locals
.nav__item_lnk-type_socials

Toggle between content with Bootstrap

I am using Twitter Bootstrap.css.
I have a top navigation bar which will normally show a menu with hover-over popup for sub items.
But when the collapsed is set due to #media constraints, I want to show the content as nested <select> and <Option> elements.
Clicking the menu button will show content like this:
I am not sure how to perform an inverse collapse. I have tried collapse, collapse.in, etc. styles.
I want to show one content when collapsed and another if not collapsed. Both content areas need to show in the navbar area.
I would like to do pure CSS with no javascript.
The following is the HTML I want to hide when callapsed. I have not created the HTML with the select/option tags yet.
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav" ng-if="userData.isAdminUser" style="cursor: pointer;">
<li class="dropdown">
<a>Managment</a>
<ul class="dropdown-menu">
<li>Employees</li>
<li>Groups</li>
<li>Products</li>
<li>Skills</li>
<li>Levels</li>
</ul>
</li>
</ul>
</div>

Bootstrap justified nav items with caret

My problem is the carets are sliding under the texts in justified bootstrap menu. Like this: http://www.bootply.com/VWo8Oc7mVz
Is there any automated method to have the carets next to title of menu item in justified mode? I have only 1 solution now, i define the widths for every menu item with css, but it is not an effective solution.
Edit: in my development site I already tried reducing the horizontal padding of the anchor elements. It didnt work, there are too much menu item. I refreshed the bootply link also with this.
This happens because the anchor tag under nav has certain padding around by bootstrap. You can reduce left and right padding and giving enough space to caret by adding
.nav>li>a{
padding : 10px 5px;
}
Demo : http://www.bootply.com/0GpdHsNVB4
As you can find in documentation "Pills with dropdowns":
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
...
</ul>
</li>

Drop down leaves gap in navigation when hidden

I'm trying to make my current CSS navigation responsive for mobile devices.
I currently have it set up with a media query so that when the screen width falls below the specified size it changes to block form (stacked) and a menu icon appears on the right hand side of the logo (to later be made into a button).
The problem I'm currently having is that the drop down menu which is used for my second link in the navigation, is causing a gap to appear between the second and third link (as if the drop down content is taking up the space whilst hidden).
I've tried looking for solutions but can't seem to find the right answer for my particular setup. Basically, the link "How It Works" should sit right beneath "Sections" when on mobile.
http://jsfiddle.net/fc45c7p5/
<a href="#">
<img class="logo" src="images/logo.png" alt="Logo" style="width:330px;height:100px"/>
</a>
<div id="menu-icon"></div>
<br></br>
</div>
<div class="navbar">
<ul class="navbar cf">
<li>HOME</li>
<li>SECTIONS
<ul>
<li>RETAIL</li>
<li>HOTEL</li>
<li>RESTAURANT</li>
<li>SHOPPING</li>
</ul>
<li>HOW IT WORKS</li>
<li>OUR EXPERIENCE</li>
<li>TESTIMONIALS</li>
<li>NEWS</li>
<li>CONTACT US</li>
</ul>
</div>
Don't take too much note of the media query max-width of 1008px, I'm aware this isn't standard mobile size, it's just temporary whilst I get it working first.
Any help regarding this is really appreciated.
visibility keeps your elements there without displaying them. You should use display:none when you do not want show the space the hidden element takes. Use display:block to show them again. Add some CSS transitions to the height of the a elements to make the reveal somewhat smoother.
Here : http://jsfiddle.net/6eshy7n2/
Add the following.
ul.navbar ul li { float: none; width: 100%; display:none;}
ul.navbar li:hover > ul li{display: block;}
You have to make the lis inside the uls actually not display when the parent li is not being hovered. When it is hovered you then change the display value to block to make it visible.

Bootstrap 3 dropdown menus

I'm new to Bootstrap/PHP, so please be gentle :-)
The code is as follows:
<div class = "navbar navbar-inverse navbar-fixed-bottom">
<div class = "container">
<p class = "navbar-text pull-left">Copyright 2014 by ABC</p>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Support<b class = "caret"></b>
<ul class = "nav navbar-nav navbar-right dropdown-menu">
<li>Help</li>
<li>FAQ</li>
<li>How To</li>
</ul>
</li>
</ul>
</div>
</div>
This creates a navbar on the bottom of the page with a drop-up menu.
The navbar has an inverse colour, so the text has been set to white to maximise the contrast.
Unfortunately the result is white text on a white background when attempting to select from the menu.
My guess is that I need to override Bootstrap's CSS, but I'm not sure what to override.
And I would prefer not to screw with Bootstrap's CSS file just in case I blow everything.
Many thanks
You have overridden link color by adding an inline style style="color: #ffffff;". This is a bad practice as it’ll take precedence on all other declarations to this element (:hover, :active, …).
If you want to change Bootstrap defaults, you should better do it in a separated CSS file. In this case the style would be:
.navbar-inverse .navbar-nav>li>a {
color: white;
}
You have extra classes on your dropdown
<ul class="nav navbar-nav navbar-right dropdown-menu">
It should be
<ul class="dropdown-menu">
You can see the result here.
The above ans, by LeBen is pretty much fine. But, while working on Bootstrap, keep an eye while overriding Bootstrap CSS. You can easily play it first in Firebug then override, and place a common comment with its description so you can easily make it out. And, while overriding make sure it wont affect the other part in the project, so think before overriding it