Pushed content with Semantic UI visible sidebar is too wide - semantic-ui

When using a visible Semantic UI sidebar the content in pusher is too wide. It has the width of the browser window, not the width of the available space.
<div class="pushable">
<div class="ui left vertical inverted visible sidebar menu">
<a class="item" href="/">Item</a>
</div>
<div class="pusher">
My content
<table class="ui red table"><thead><th>1</th></thead>
<tbody><td>Test</td></tbody>
</table>
</div>
</div>
See a jsfiddle here:
http://jsfiddle.net/xh9p6tgb/1/

If you want to have an always visible sidebar-like element, then you could try using just Semantic UI Menu instead of sidebar. It's built in classes should be enough so that you can use it as a side menu and scale your content accordingly.
The sidebar isn't designed to automatically scale content that is within the pusher element. Instead, it it designed to be a transient menu which will either overlay or push content to the side.
You can change sidebar animation types during initialization using the animation option, for example:
// Add javascript here
$(document).ready(function() {
$(".ui.sidebar").sidebar({
transition: 'overlay'
});
});
However, if you want the sidebar to be animated but also have a pinned function, then you will most likely have to implement that yourself. Possibly something like adding a pinned class to the sidebar, or just use the visible class to determine if the pusher should shrink by using some CSS:
.ui.sidebar.visible ~ .pusher {
width: calc(100% - 260px);
}
Unfortunately, the animation looks a little strange like this but it's usable.
You can see it here http://jsfiddle.net/rkkmLtzn/

Related

Basic d3 tooltip/styling - graphic being offset

I've just started experimenting with d3.js, and have been trying to add functioning tooltips. I should note that I've also never worked with tooltips before this experimentation. I'm under the impression that this should be a fairly simple question to answer:
When I mouse over one of my targets, the div into which I placed the tooltip (above my graphic) goes from a height of 0px to however much space is needed to display the text (or a specified height). I was under the impression that if the position was relative, the div effectively moved. This is problematic because it pushes my page down by whatever height it needs whenever a tooltip is displayed, which is pretty disruptive.
You can see exactly what's happening here: http://jsfiddle.net/76analytics/u6tnyqgc/14/
As an aside, I was also wondering why putting that div below my graphic disabled the tooltip altogether.
<title>D3 Graphic </title>
<body>
<div id="tooltip" class="hidden"></div>
<div class="container">
<h2>D3 Graphic </h2>
<div id="chart"></div>
</div>
</body>

jquery mobile issue with data-column-btn positioning when allowing horizontal scrolling

I am showing a data table in jquery mobile using the column toggle button for a responsive design. However, I've also added <div style="overflow:auto"> so that the user is able to scroll horizontally, if they choose to be able to view too many items for the screen (some may argue that this defeats the purpose but this is to display reports so the user may want this feature).
Anyway, my problem is that when the user scrolls horizontally along the table, the data-column-btn gets moved along with the rest of the table. Is there a way that I can "stick" the button to the top right hand corner, so even as the rest of the table scrolls, the button remains in the same position?
JS Fiddle here: http://jsfiddle.net/LuA8m/
Thanks everyone :)
You can use JavaScript to move the button into another DIV. First create an empty placeholder DIV above the table wrapper and give the table wrapper DIV a width of 100%:
<div id="colTogglePlaceholder"></div>
<div style="overflow:auto; width: 100%; ">
<table data-role='table' data-theme='a' id='customerListTable' data-mode='columntoggle' class="ui-body-b ui-shadow table-stripe ui-responsive" data-column-btn-mini="true" data-column-btn-text="Columns to Display" data-column-btn-corners="false" data-column-btn-theme="c" data-column-popup-theme="a" >
<thead>
<tr>
etc.
Then use the jQuery appendTo() method to move the button into the placeholder DIV:
$(document).on("pageinit", "#customerList", function () {
$(".ui-table-columntoggle-btn").appendTo("#colTogglePlaceholder");
});
Here is your updated FIDDLE
NOTE: this also works in jQM 1.4

Display div after its actual position

I am not sure if this is possible. I have a page setup like this:
<div class="sidebar">
</div>
<div class="main">
</div>
The sidebar is set to float:right. It's fine apart from when I resize the window down (as it's responsive), the sidebar appears above the content. It's set to position:static and has no float.
Is it possible to make the sidebar appear 'after' the "main" div when in responsive mode - through CSS only? I can't think of a way to do it using pseudo-elements etc.
PS: I cannot move the .sidebar div down below the .main div in the HTML, because then Google decides it doesn't want to show my author avatar as it's "not relevant" i.e. too far down so ignores it.
Google showing your avatar is not the result of how far down it is. Google looks for this bit of html:
rel=author
See this article: http://searchengineland.com/googleplus-slowly-invading-googles-main-search-results-102416
Once you do that you can switch the order of your html to have "main" first, and then float "main" and "sidebar" left at the appropriate breakpoint.

jQuery Mobile, collapsible key-value grid: sizing header 50/50 with icon

I have a bunch of tabular/key-value data, of which I always show one item and the rest when the user clicks on the first, like this jsFiddle:
<div data-role="collapsible">
<h3><div class="ui-grid-a">
<div class="ui-block-a">Customer:</div>
<div class="ui-block-b">Mario's Plumbing</div></div></h3>
<ul data-role="listview">
<li><div class="ui-grid-a">
<div class="ui-block-a">Phone:</div>
<div class="ui-block-b">1-800-MUS-ROOM</div></div></li>
...
</ul>
</div>
However, when jQuery Mobile adds an icon to the header item ("Customer: Mario's Plumbing"), the value field, i.e. "Mario's Plumbing", doesn't align with the value fields in the <ul> list, i.e. "1-800-MUS-ROOM".
I think jQuery puts the icon side-by-side with the "Customer: Mario's Plumbing" box---this is compatible with what I see: the misalignment looks roughly like 100% of a button width for the key field and 50% of a button for the value field, which I would expect given my use of a ui-grid-a (which does a 50/50 split). I would want the icon to be part of the left 50%, i.e. inside rather than beside that box. Can I do that? How? It might be easy CSS and me being a CSS retard :)
It looks like the jQuery mobile element styles are not playing nicely together, in this case the collapsible block and the grid layout styles.
The collapsible block adds the icon and the style which pads the header.
.ui-btn-inner {
padding:.6em 20px;
}
The additional rule, pads the left even more (to move the text away from the icon)
.ui-collapsible-heading .ui-btn-inner, .ui-collapsible-heading .ui-btn-icon-left .ui-btn-inner {
padding-left: 40px;
}
but this pushes all the header text left by 40px.
The only way I could find to correct the mismatch is to add an additional rule to move the second block to the left. By adding the following rule, the text lines up again.
.ui-collapsible-heading .ui-btn-inner .ui-grid-a .ui-block-b {
margin-left:-10px;
}
It seems to work fine at different page zoom levels in my local Chrome browser testing but I have not tested on a mobile device.
Edit: Also, there is a typo in the example and the fiddle, you have un-block-b and not ui-block-b for Mario's Plumbing.

Dynamically stretch content based upon number of fixed-width columns

I've worked with CSS enough that I can get columns to work alongside content if I have a set number of columns: I simply define the sidebar(s) in the HTML prior to the content, and specify that they float to the left or right, while giving the content a margin-left or -right such that it doesn't flow into the space below the end of the sidebar.
I have a new challenge though, whereby the number of columns may vary between pages. In my HTML, I don't want to specify the sidebar content prior to the main page content though, which is the only way I know how to do it.
Essentially, I want the HTML to look like this:
<div id="container">
<div id="content">
<!-- Main body content goes here. -->
</div>
<div class="sidebar">
<!-- Sidebar DIV should appear to the right of the content DIV. -->
</div>
<div class="sidebar">
<!--
Another sidebar DIV, with this one *preferably* appearing to the
right of the one above, since it appears lower in the code and is
assuming LTR. I'm open to CSS that makes this sidebar appear to
the left instead of the right, however.
-->
</div>
<!-- Any number of additional sidebar DIV's can appear here. -->
</div>
I'm not sure if I should be trying to float the content/sidebar DIV's, make them position absolute, specify the width, etc. to make the content stretch automatically with the variable number of sidebars. It's probably worth noting that the size of each sidebar will be constant.
div.sidebar {
width: 100px;
}
On final note: if there's an improvement I can make to the HTML that will help, (e.g.: surrounding all the sidebar DIV elements in a parent DIV such as <div id="sidebars">), I'm open to suggestions there as well.
I guess I'll have to accept the fact that this requires HTML tables since no one can offer a CSS solution for this.

Resources