I am new to Semantic-UI and am having trouble with getting any modules to work; other Semantic-UI elements seem to be working (e.g. button animations). But for some reason none of the modules seem to be functioning properly. Specifically I have been try to set up tabs on a page, the tabs are clickable, but all the content of ALL the tabs is being displayed below when it should be hidden (except for the clicked tab ofcourse). I'm running Semantic UI with node js v10.1.0 and jquery 3.1.1., editing and opening with Visual Studio Code. I have followed the set up of Semantic as per their website.
I have tried different modules (e.g. accordion, dropdown) but none of the others seem to function properly either. I'm just trying to run the code from the website to no avail. I have tried reinstalling semantic ui, which did not seem to fix it. (I do note that whenever I have installed semantic ui there always appear to be warnings about deprecated packages/files but everything still installs).
HTML:
<div class="ui top attached tabular menu">
<a class="item active" data-tab="first">First</a>
<a class="item" data-tab="second">Second</a>
<a class="item" data-tab="third">Third</a>
</div>
<div class="ui bottom attached tab segment active" data-tab="first">
First
</div>
<div class="ui bottom attached tab segment" data-tab="second">
Second
</div>
<div class="ui bottom attached tab segment" data-tab="third">
Third
</div>
JS:
$('.menu .item').tab();
None of the tabs function as tabs. All content is displayed that should be hidden by tabs.
I have solved the issue. It appears the css files from the saved semantic-ui files were not being detected through my href statements; it was fixed by changing the href tags linking to the files to instead link to the cloudflare links.
Related
Background: At time of writing, Fomantic-UI is the live-development fork of Semantic-UI which will one day be rolled into Semantic-UI and is for the mean time the de facto supported genus of Semantic-UI.
Issue: The tabbed metaphor is well understood and in some use cases includes the ability to close a tab via an X icon - think of multi-document editors such as VS Code, etc. Fomantic-UI has a good tab component but no automatic means of including a close icon, and good button and icon components with many options. It also offers the ability to combine components - with much power great responsibility comes - and I find that sometimes a little pointer would be useful. Therefore I provide this snippet to suggest some potential solutions.
Something like this is the target...
See my answer below.
The snippet below illustrates my answer. For me the tertiary button & icon combination are the best option. Although the height of the tab is affected by inclusion of the buttons and will need to be worked on.
As a bonus the JS in the snippet shows how to close a tab on click of the close icon.
Note: This snippet is using the the 'dist' versions of FUI. Since FUI changes often, the snippet may fail if there have been breaking changes by the time you see it. At time of writing the official release on jsdelivr cdn is 2.8.3. (#17-Jan-2020).
$('.menu .item')
.tab();
$('.tabCloser').on('click', function() {
// get the parent of the icon, meaning the anchor.
var parent = $(this).parent();
// get the tab name from the anchor.
var tabName = parent.data('tab');
// erase elements with the matching tab name
$('[data-tab=' + tabName + ']').remove();
// Click the first remaining tab if any.
if ($('a.item').length > 0){
$('a.item').first().trigger('click');
}
})
.daContent {
margin: 2em;
}
<link href="https://fomantic-ui.com/dist/semantic.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://fomantic-ui.com/dist/semantic.js"></script>
<body>
<div class='daContent'>
<p>
The tabs below illustrate 3 options:
<ul>
<li>First uses a button of class <i>ui basic icon button</i></li>
<li>Second is a simple icon with class <i>close icon</i></li>
<li>Third uses a button with class <i>ui tertiary icon button</i></li>
</ul>
None require additional JavaScript or CSS.
</p>
<div class="ui top attached tabular menu">
<a class="active item" data-tab="first">First
<button class="ui basic icon button tabCloser">
<i class="close icon"></i>
</button>
</a>
<a class="item" data-tab="second">Second <i class="close icon tabCloser"></i></a>
<a class="item" data-tab="third">Third
<button class="ui tertiary icon button tabCloser">
<i class="close icon"></i>
</button>
</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="first">
Ideally there should be no border around the button, and for mouse users a mouse-over UI change without reverting to additional code.
</div>
<div class="ui bottom attached tab segment" data-tab="second">
Better - no border, but also no mouse-over UI effect. And the icon cramps the tab text too much. We could fix both with custom CSS / JS but the aim is for no additional code.
</div>
<div class="ui bottom attached tab segment" data-tab="third">
Best - no border, plus a mouser effect.
</div>
</div>
</body>
My navbar is currently closed as default (navbar only shows on mobile).
Is there some css that will default the nav bar to open?
I currently have no code as I'm trying to edit a template. I believe it's a bootstrap navbar.
Site: yodega.com (on mobile, or small screen)
Thanks!
It is not supported by default:
https://github.com/twbs/bootstrap/issues/3944
There is simple and fast but not clean solution:
You can simulate clicking on navbar element after page rendering:
document.querySelector('button.navbar-toggle').click()
Method click is described in link:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click
There is also better solution but it require to change your source code.
When your page is rendered you can find something like this:
<div class="navbar-collapse navbar-top-collapse collapse" style="height: 0px;">
You can simply change it on this:
<div class="navbar-collapse navbar-top-collapse in" style="height: auto;">
Probably style="height: 0px;" is added by your library, and you should overwrite this behavior.
Currently I am working on huisartsendorpsstraat.zoetermeergezond.nl/care-practicioners to toggle the workers divs.
What I am trying to accomplish is to only show a maximum of 9 workers, after that a button displays with the show more workers text.
Getting the button ain't no problem, just added it in the footer of the view, but to make it toggle the divs it ain't just not working.
I made sure a .js file is being called from the theme.php file of the theme.
I ain't no Drupal expert, so I am sorry if I am asking stupid questions here.
Has anyone found a way to toggle the divs created inside a view?
Layout:
<div class="views-row views-row-1 views-row-odd views-row-first"></div>
<div class="views-row views-row-2 views-row-even"></div>
<div class="views-row views-row-3 views-row-odd"></div>
<div class="views-row views-row-4 views-row-even"></div>
<div class="views-row views-row-5 views-row-odd views-row-last"></div>
thanks a bunch
I would recommend using one of these modules:
https://www.drupal.org/project/views_load_more
https://www.drupal.org/project/views_show_more
They both do same thing basicly -> there are some slight differences. Personally i use the first one. It's quick and easy to set up, no additional custom JS needed. Just install, enable, change your views footer to Views Load More and configure. Good luck!
I am using a Bootstrap Template, that you can see the live version here - https://02dc74ce3e31e56a52ebcc845dca58e87283aabe.googledrive.com/host/0Bxbofwq0kd4ReUt2YWVOYmt3WVU/
If you view it on a mobile device, you will see how the responsiveness of Bootstrap kicks in.
But when I applied it to my Rails app, the mobile version does not look the same.
Any ideas what may be causing the discrepancy?
You can see the differences especially in both the main 'content' area with the story (notice on my version you see multiple stories in the main view, but on the original you only see 1 story and you can read the content more easily). You can also see it when you press the buttons.
Press the 'blue' button to the right top of the original and you will notice that the sidepanel comes out at the top like it should. But on my version it still comes to the side and everything is small.
What am I missing?
Thanks.
Add this to your application.html.erb:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
You have made too many changes while you are implementing the html in your rails view.
Like original header have following content :
<header class="header">
<hgroup class="pull-left">
<h1 class="site-title">
<a href="index.html" title="Von" rel="home">
<i class="fa fa-lemon-o"></i> Von
</a>
</h1>
</hgroup>
<div class="btn btn-primary pull-right" id="togglesidebar">
<i class="fa fa-bars"></i>
</div>
</header>
But in your view instead of <hgroup class="pull-left"> you have <hgroup class="pull-left col-xs-3 col-sm-3 col-md-3 col-lg-3"> and for <div class="btn btn-primary pull-right" id="togglesidebar"> you have <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 masthead-group-3"> also You added two more element in between these two element that destroyed your all header view.
You haven't used middle section from html design it seems you write your own. In your <header class="entry-header"> You created div instead of image tag. So every thing started distorted here. You include header footer section for each main section. But it's not big issue. Try remove div for confirmed and unconfirmed and use image instead. SO you will have proper view. Also remove row class from view that you added so view look more symmetric.
In your about section. When you try to see on mobile view. width of main container <div style="display: inline-block;" class="col-sm-3 sidebar" id="secondary"> is calculated on the basis of it's child element like <div class="about">. As your child element is form and it's having width less than the width displayed on form so remaining section not having proper background color #1c171e. So try increase width of you form control or <h4>Submit Report</h4> like <h4>Submit Report </h4> (kind of hack)under about section You will get proper view for this also.
Judging by your css file, you have loaded similar css multiple times. Consider the fact that, if everything else suggested by the people above has been corrected, the placement of the css files in the application scss file could overwrite your correct code.
I would also check the viewport meta tag as suggested above
If you try calling the CSS and JS being used as individual standalone files, instead of minified, do you still have this issue? Order of these files will matter too. I've seen lots of quirky issues when one JS gets loaded before another, same goes for CSS.
P.S. I would leave this information as a 'Comment' vs. Answer but I don't have enough stack overflow credit yet to do so ;-)
Make sure that if you have using rails g scaffold that you remove the scaffold.css file.
I know questions about broken links get asked all the time, however my issue seems a bit different, and none of the solutions have worked.
Right now none of the links to other websites in my nav section worked when clicked. It registers that they are there, and if you right click it and select "open in new tab" it works, but otherwise, nada. A few relative links (if thats the term for the href="#xxx" link to content on the page) to modal popups work fine though.
My HTML Code is listed below, as well as a Pastebin link to the CSS (so that I don't clutter up the box).
Removing the class="navigation" from the list tag seems to fix the link issue. Leaving the class on the tag but removing all the relevant CSS from the stylesheet, however, does not eliminate the issue and just removes the styling. I can't figure out why this would be the case.
I've tried setting the z-indices of my background, menu and nav to 1,2,3 (and 3,2,1 just for the hell of it) respectively so that they don't interfere, as recommended in other questions here, but to no avail. Anyone have any ideas?
CSS: http://pastebin.com/1KVTdBvF
Site: http://www.magratheamedia.com/npo
<div class="menu">
<div class="container clearfix">
<div id="logo" class="fleft">
<img src="images/logo.png" />
</div>
<div id="nav" class="fright">
<ul class="navigation">
<li data-slide="1">Home</li>
<li>Forum</li>
<li>Wiki</li>
<li>Government</li>
<li>Charter</li>
<li>In-Game</li>
<li>Applicants</li>
<li>IRC</li>
<div class="clear"></div>
</ul>
</div>
</div>
Your problem isn't CSS, it's your jQuery. This, in particular:
links.click(function (e) {
e.preventDefault();
dataslide = $(this).attr('data-slide');
goToByScroll(dataslide);
});
When you find your links, like this:
var links = $('.navigation').find('li');
You have to somehow exclude the ones that go to external sites. Maybe by giving the modal links their own class name or something.