Custom logo with link to homepage - css

I have a trouble to add custom logo with link to navbar if we scroll down
is class "dropdown-menu dropdown-inverse"
site: http://its-skin.upgates.com
CSS:
.secondlogo {
background-image: url(http://static.its-skin.upgates.com/m/m57daee4256187-sublogo.png);
width: 250px;
height: 54px;
margin-left: auto;
margin-right: auto;
}
here is the code full code :
<ul class="nav navbar-nav top-menu top-menu-categories">
{else}
<ul class="dropdown-menu dropdown-inverse" data-designer="d1-2-2-1">
{/if}
{foreach $tree as $category}
<li class="ct_{$category['category_id']} lev-{$level}{if $category['active']} active{/if}{if count($category['childs'])} dropdown{if $level > 1} dropdown-submenu{/if}{/if}" data-target-category="{$category['target_category_id']}">
<a href="{$category['url']}"{if $category["blank_yn"]} target="_blank"{/if} class="TopMenuLink">
{$category['name']}
{if (count($category['childs']))}
<i class="caret"></i>
{/if}
</a>
{if count($category['childs'])}
<button class="btn SubcategoriesLink"><i class="fa fa-chevron-right"></i></button>
{/if}
{include #desktopMenu tree => $category['childs'], level => $level + 1, option => false, colsCount => ceil(count($category['childs'])/$itemsInCol)}
</li>
{/foreach}
</ul>

You could add another list element at start of your ul which holds the link
<ul class="nav navbar-nav top-menu top-menu-categories">
<!-- New Element with class logolink -->
<li class="ct_29 lev-1 logolink">
<a href="http://its-skin.upgates.com/" class="TopMenuLink">
Link
</a>
</li>
<li class="ct_29 lev-1" data-target-category="29">
<a href="http://its-skin.upgates.com/krasa-it-s-skin" class="TopMenuLink">
Krása It's Skin
</a>
</li>
...
</ul>
Then just use css to put your logo in front of it
.logolink {
background-image: url(http://placehold.it/16x16/ff0000);
background-position: left center;
background-repeat: no-repeat;
padding-left: 20px; /* Adjust to your logo size*/
}
Example:
In case you want just a clickable logo image without text, wrap it inside the hyperlink <img src="#" /> and forget about the background-image in css.
EDIT:
If you want a fade-in effect when a user scrolls your page have a look at these two excellent jquery libraries which provide this functionality.
http://scrollmagic.io/
http://johnpolacek.github.io/scrollorama/
Alternative you can fade in with some jquery code. Therefore hide the logo (element) by setting it´s opacity to 0, detect the viewport scrolling and fade it in at some point. Find a working example here:
https://jsfiddle.net/mwtebtw9/1/
Code taken from: http://www.ordinarycoder.com/jquery-fade-content-scroll/

Related

Change direction of Bootstrap Dropdown on React

I'm trying to display a navbar Dropdown to open to the left, but it keeps opening to the right. My dropdown is located at the far right of the navbar and when I open it, it opens to the right, going outside of the layout.
I've already tried the "pull-right" and "pull-left" solutions to no avail. Also the "dropdown-menu-right" and "dropdown-menu-left" solutions don't work.
html5
<ul className="nav navbar-nav navbar-right">
<li className="nav-item dropdown">
<a className="nav-link" id="walletOptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src={require('../img/wallet.svg')} alt="easyfeedbacktoken" height="40px" />
</a>
<ul className="dropdown-menu" aria-labelledby="walletOptions">
<ImportMnemonicModal onUpdateMnemonic = {this.props.onUpdateMnemonic}/>
<ShowMnemonic mnemonic = {this.props.mnemonic}/>
<DeleteWallet onUpdateMnemonic = {this.props.onUpdateMnemonic}/>
</ul>
</li>
</ul>
I want the dropdown menu to drop to the left. It always drops to the right.
Try changing it from a dropDOWN to a dropLEFT.
That way it always opens to the left
Change :
<li className="nav-item dropdown">
To :
<li className="nav-item dropleft">
Complete code :
<ul className="nav navbar-nav navbar-right">
<li className="nav-item dropleft">
<a className="nav-link" id="walletOptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src={require('../img/wallet.svg')} alt="easyfeedbacktoken" height="40px" />
</a>
<ul className="dropdown-menu" aria-labelledby="walletOptions">
<ImportMnemonicModal onUpdateMnemonic = {this.props.onUpdateMnemonic}/>
<ShowMnemonic mnemonic = {this.props.mnemonic}/>
<DeleteWallet onUpdateMnemonic = {this.props.onUpdateMnemonic}/>
</ul>
</li>
</ul>
Source bootstrap (https://getbootstrap.com/docs/4.0/components/dropdowns/#dropleft-variation)
The Dropleft, Dropup and Dropright solutions didn't worked in my particular situation.
Neither the "pull-right" or "pull-left" solution.
I was able to force the Dropdown to drop into a specific coordinates using the following solution:
.nav .dropdown{
cursor: pointer;
position: absolute;
left: 88%;
top: 30%;
}
.dropdown-menu{
cursor: pointer;
position: absolute !important;
left: -8em;
top: 3em;
}
Making the dropdown button be in a specific position and the dropdown menu drop exactly how I wanted it to.
For Smaller devices, I just used #media and put another set of rules in order for the dropdown menu to work properly.

Conditionally apply a CSS [duplicate]

This question already has an answer here:
Apply style to element, only if a certain element exists next to it
(1 answer)
Closed 5 years ago.
I have a style defined that needs to be applied only if there is an icon, but not if there isn't.
The html structure with an icon is as follows:
<li class="g-menu-item g-menu-item-226 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/services/visas">
<i class="fa fa-id-badge"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">Visas</span>
</span>
</a>
</li>
The structure without an icon is as follows:
<li class="g-menu-item g-menu-item-232 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/destinations/australia/adelaide">
<span class="g-menu-item-content">
<span class="g-menu-item-title">Adelaide</span>
</span>
</a>
</li>
The SCSS I have worked fine on items with an icon. It moves the span with the class g-menu-item-title to the right by 1.25rem and up by 1rem:
.aside-nav {
.g-menu-item-container {
.g-menu-item-content {
margin-left: 1.25rem !important;
margin-top: -1rem !important;
}
}
}
However, when there is no icon, it makes the menu items in the sidebar squished into each other.
How do I change this SCSS so that it only applies to menu items in the aside where the item has an icon, but not when there isn't an icon.
You can use an Adjacent sibling selector,
It'll let you target an element that is next to another element:
i + .g-menu-item-content {
margin-left: 1.25rem !important;
margin-top: -1rem !important;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<ul>
<li class="g-menu-item g-menu-item-232 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/destinations/australia/adelaide">
<span class="g-menu-item-content">
<span class="g-menu-item-title">Adelaide</span>
</span>
</a>
</li>
<li class="g-menu-item g-menu-item-226 g-menu-item-type-component g-standard">
<a class="g-menu-item-container" href="/en/services/visas">
<i class="fa fa-id-badge"></i>
<span class="g-menu-item-content">
<span class="g-menu-item-title">Visas</span>
</span>
</a>
</li>
</ul>

D3 Elements are invisible despite existing in DOM

I have a bootstrap tab panel and I want to display a different d3 chart for each tab.
When the document loads, the first D3 chart is present in the DOM but its elements are invisible. Here's an example: http://i.imgur.com/7ATTyhI.png
Here is the setup for my tab pane in bootstrap:
<div role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#ghg-co2" aria-controls="ghg-co2" role="tab" data-toggle="tab">
<h4>Change in CO<sub>2</sub></h4></a>
</li>
<li role="presentation"><a href="#ghg-ch4" aria-controls="ghg-ch4" role="tab" data-toggle="tab">
<h4>Change in CH4 (Methane)</h4></a>
</li>
<li role="presentation"><a href="#ghg-nos" aria-controls="ghg-nos" role="tab" data-toggle="tab">
<h4>Change in Nitrous Oxide</h4></a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<script src="js/ghg.js"></script>
<div role="tabpanel" class="tab-pane active fade fade-in" id="ghg-co2">
<div id="chart-ghg-co2" class="d3-chart"></div>
</div>
<div role="tabpanel" class="tab-pane fade fade-in" id="ghg-ch4">
<div id="chart-ghg-ch4" class="d3-chart"></div>
</div>
<div role="tabpanel" class="tab-pane fade fade-in" id="ghg-nos">
<div id="chart-ghg-nos" class="d3-chart"></div>
</div>
</div>
</div>
I have had issues with bootstrap displaying content in the tab pane correctly. I am using this hack in my style.css to override some bootstrap properties:
/* bootstrap hack: fix content width inside hidden tabs */
.tab-content > .tab-pane,
.pill-content > .pill-pane {
display: block; /* undo display:none */
height: 0; /* height:0 is also invisible */
overflow-y: hidden; /* no-overflow */
}
.tab-content > .active,
.pill-content > .active {
height: auto; /* let the content decide it */
} /* bootstrap hack end */
I got it from this thread
My D3 function is almost identical to this example: d3 scatterplot
but with different data.
At the bottom of my HTML, I have:
<script>
// Check if DOM is ready for D3
$( document ).ready(ghgco2()); // Names of my three D3 chart functions
$( document ).ready(ghgch4());
$( document ).ready(ghgnos());
</script>
I suspect the problem is that my d3 function, ghgco2() is attempting to render before the div in which it resides, .chart-ghg-co2 is ready. For some reason, the svg has the correct dimensions, and the elements are all present, but it's completely blank. This is resolved when I switch between tabs on the bootstrap pane.
Any and all help is appreciated.

angular-bootstrap dropdown on mouseenter and keep dropdown-menu from hiding before being clicked.

First, I'm aware of this posts:
Activating bootstrap dropdown menu on hover
Bootstrap Dropdown with Hover
How to make twitter bootstrap menu dropdown on hover rather than click
And others, but still not found the correct solution yet, here's what I did so far.
first I used the is-open attribute from the angular-bootstrap dropdown directive like this:
<span class="dropdown" dropdown is-open="status.isopen">
<a
href
class="dropdown-toggle"
ng-mouseenter="status.isopen = true"
ng-mouseleave="status.isopen = false"
>
hover me for a dropdown with angular-bootstrap
</a>
<ul
class="dropdown-menu"
>
<li ng-repeat="choice in items">
<a href>{{choice}}</a>
</li>
</ul>
</span>
that seemed to work but 2 bugs appeared:
the first is when dropdown-toggle element is clicked the dropdown menu is gone clicking again wont bring it back you have to mouseleave then mouse enter the dropdown-tooggle to get the dropdown-menu back.
the second is a css/html problem.
Usually the regular css solution for a dropdown is like this:
<a class="css-dropdown">
hover here with css.
<div class="css-dropdown-menu">
<p>item 1</p>
<p>item 2</p>
<p>item 3</p>
</div>
</a>
Notice the dropdown-menu now is inside the dropdown-toggle element which mean when moving with the mouse from the dropdown-toggle to the dropdown-menu it's moving from parent to child, so basically we still hovering over the dropdown-toggle since we are in it's child, which mean the dropdown-menu will still be visible, on other hand, the bootstrap dropdown works with the click event so having the dropdown-menu as a child of the dropdown-toggle is not needed, but now when someone wants to change the behavior to mouseenter/hover once the mouse leaves the dropdown-toggle the dropdown-menu disappear so we no longer have access to the dropdown-menu elements this is visible in this plunker
To fix the first bug, I just removed the dropdown directive then replaced the is-open with ng-class directive like this.
Change this:
<span class="dropdown" dropdown is-open="status.isopen">
to this:
<span class="dropdown" ng-class="{'open': status.isopen}">
The rest stays the same plunker that fixed the first bug.
The second bug is tricky, since the dropdown-menu is no longer a child of the dropdown-toggle the hover effect wont last while moving from the toggle to the menu, so I did this.
Changed this:
<ul class="dropdown-menu">
to this:
<ul
class="dropdown-menu"
ng-mouseenter="status.isopen = true"
ng-mouseleave="status.isopen = false"
>
That did it but another bug appeared when clicking the dropdown-menu item it stays open, so I kept hacking by doing this.
changed this:
<li ng-repeat="choice in items">
to this:
<li ng-repeat="choice in items" ng-click="status.isopen = false">
That give me the required behavior plunker.
That said, this is not a good solution since a lot of directives are involved here for a simple visual effect, the last plunker I provided contains a css solution with no Bootstrap or AngularJS involved, though it is the required behavior it is not the required html structure or visual result, what I need is to have a space between the dropdown-toggle and the dropdown-menu not a padding of the toggle element just an empty space, which make the css solution not valid in this situation.
So, my question is there a better way of doing this without adding a new plugin/library more clean and easily reusable solution for the hover drop down menu?
First, have the toggling on the top-most parent element (in this case, the <span>)
<span class="btn-group" dropdown is-open="status.isopen" ng-mouseenter="status.isopen = true" ng-mouseleave="status.isopen = false">
<a class="btn btn-primary dropdown-toggle" dropdown-toggle>
Button dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</span>
This will allow the behavior you wanted - while still allowing clicking to show/hide the menu ;-)
However there's an annoyance: if you move the mouse cursor slower and pass the small gap between the toggle and menu, it will hide the menu.
So secondly, add a small CSS to remove the gap
.dropdown-menu {
margin-top: 0;
}
See the action in this plunker.
I know you want a solution without adding a new plugin/library, but you (or others seeking for this behavior) might want to try using No Close from Dropdown Enhancements lib to keep the dropdown open even after clicking in one of its options:
Do not close the menu on click on radio add class .noclose.
<div class="btn-group">
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
Checked option <span class="caret"></span>
</button>
<ul class="dropdown-menu noclose">
<li>
<input type="radio" id="gr1_1" name="gr1" value="1">
<label for="gr1_1">Option 1</label>
</li>
<li>
<input type="radio" id="gr1_2" name="gr1" value="2">
<label for="gr1_2">Option 2</label>
</li>
<li>
<input type="radio" id="gr1_3" name="gr1" value="3">
<label for="gr1_3">Option 3</label>
</li>
</ul>
</div>
Also add a CSS solution for the hovering problem:
.btn-group:hover .dropdown-menu.noclose {
display: block;
}
.dropdown-menu.noclose {
margin-top: 0px;
}
And, of course, don't forget to import the libs:
<script src="./js/dropdowns-enhancement.min.js"></script>
<link href="./css/dropdowns-enhancement.css" rel="stylesheet"\>
In your case I suggest you to study the Dropdown Enhancements's source code to see how it works and maybe find a more suitable solution.
Try adding this line to your css:
.btn-group:hover>.dropdown-menu { display: block; margin-top: 0; }
You'll have to remove your is-open, ng-mouseenter and ng-mouseleave directives.
Below is the solution I came up with, while working on the same issue.
I used a simple custom directive that:
binds the mouseenter and mouseleave events to the dropdown in order correctly to show/hide the menu.
dynamically adds a custom CSS class to the dropdown menu in order to prevent the menu from disappearing when moving the cursor from the button to the menu. Note that this solution has the advantage of not removing the visual gap between the button and menu.
prevents the menu from disappearing when the button is clicked.
The CSS rule uses a before pseudo-element to fill the gap between the button and the menu. I added the border property which can be uncommented to easily get a visual feedback.
.dropdown-hover-menu::before {
content: '';
position: absolute;
left: 0;
width: 100%;
top: -3px;
height: 3px;
/*border: 1px solid black;*/
}
The HTML structure of the snippet is based on the available examples in the dropdown section of the angular-ui bootstrap documentation
angular.module('app', ['ui.bootstrap'])
.directive('dropdownHover', function() {
return {
require: 'uibDropdown',
link: function(scope, element, attrs, dropdownCtrl) {
var menu = angular.element(element[0].querySelector('.dropdown-menu')),
button = angular.element(element[0].querySelector('.dropdown-toggle'));
menu.addClass('dropdown-hover-menu');
element.bind('mouseenter', onMouseenter);
element.bind('mouseleave', onMouseleave);
button.bind('click', onClick);
function openDropdown(open) {
scope.$apply(function() {
dropdownCtrl.toggle(open);
});
}
function onMouseenter(event) {
if (!element.hasClass('disabled') && !attrs.disabled) {
openDropdown(true);
}
};
function onMouseleave(event) {
openDropdown(false);
};
function onClick(event) {
event.stopPropagation();
}
scope.$on('$destroy', function() {
element.unbind('mouseenter', onMouseenter);
element.unbind('mouseleave', onMouseleave);
button.unbind('click', onClick);
});
}
};
});
.dropdown-hover-menu::before {
content: '';
position: absolute;
left: 0;
width: 100%;
top: -3px;
height: 3px;
/*border: 1px solid black;*/
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.3.3/ui-bootstrap-tpls.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div ng-app="app">
<div class="btn-group" uib-dropdown dropdown-hover>
<button type="button" class="btn btn-primary dropdown-toggle">
Button dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li role="menuitem">Action
</li>
<li role="menuitem">Another action
</li>
<li role="menuitem">Something else here
</li>
<li class="divider"></li>
<li role="menuitem">Separated link
</li>
</ul>
</div>
</div>

Silverstripe Image Based Menu

I would like to create a image and text menu in Sliverstripe as shown here:
I was thinking to have jquery select an individual ID and replace the background image. How ever Silverstripe gives me the menu as you see below. How can I go about setting up this menu?
Output
<ul>
<li class="current">
<a title="video" href="/cfl/index.php/">Home</a>
</li>
<li class="link">
<a title="alarm" href="/cfl/index.php/about-us/">About Us</a>
</li>
<li class="link">
<a title="auto" href="/cfl/index.php/contact-us/">Contact Us</a>
</li>
</ul>
Template File
<nav class="primary">
<span class="nav-open-button">²</span>
<ul>
<% loop $Menu(1) %>
<li class="$LinkingMode">$MenuTitle.XML</li>
<% end_loop %>
</ul>
</nav>
Thanks.
this should be pretty easy, in SilverStripe templates you can do anything you can do in normal HTML. With additional variables and features of course.
so, you can simply give the items a ID or a css class.
let me show you an example:
<nav class="primary">
<span class="nav-open-button">²</span>
<ul>
<% loop $Menu(1) %>
<li class="$LinkingMode position-$Pos" id="$URLSegment">$MenuTitle.XML</li>
<% end_loop %>
</ul>
</nav>
you see, I added position-$Pos which will become position-1, position-2, and so on.
also, I added an ID, in this case, it will be the URLSegment of that page.
so now you can use CSS or javascript to get that item, eg here some CSS to set a background:
.position-1 { background: green; }
.position-2 { background: yellow; }
.position-3 { background: blue; }
// we can also use the ID to style the element:
#home {
display: block;
width: 100px;
height: 100px;
background-image: url(http://placehold.it/100x100);
}
in in any javascript code you can of course do the same (in your case the framework jquery):
jQuery(document).ready(function($) {
$('.position-1').hover(function() {
alert('you moved over the first item');
});
});
however, I strongly urge you to use CSS, there is no reason for using javascript to do a simple task like setting a background image.

Resources