How to make only one line list wider than screen? - css

I have a list, which length is variable,it could have 4 items or 30 items.
The issue is that this list is being rendered as a marquee, through a Javascript that is working, but items reach the screen width and then they pass to next line.
I want to have all the items on the same line, so then I could move the list to recreate the marquee effect.
<div class="submenu-container">
<div id="agrupador">
<ul style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;" class="submenu" id="moverlo">
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
<li> Item </li>
</ul>
</div>
</div>
.submenu-container {
background:#F0F7FF;
border-bottom:1px silver solid;
width: 100%;
overflow: hidden;
}
.submenu li {
display: inline-block;
margin-left:4px;
background:none;
*display: inline; /* IE */
float:left;
}
.submenu {
margin:0;
padding-top:8px;
padding-bottom:8px;
padding-left:0;
padding-right:0;
clear:none;
width:auto;
float:left;
}
And with javascript:
function ClonarAvisos(){
var width = alertSize(); // Usable window width
var xVarScreen = width - $('moverlo').getWidth();
alert($('moverlo').getWidth());
$('moverlo').setStyle({ width: $('moverlo').getWidth() + xVarScreen });
$('agrupador').setStyle({ width: $('moverlo').getWidth() * 2 });
var clon = Element.clone('moverlo', true);
clon.id = 'moverlo2';
$('agrupador').insert(clon);
}
function MoveNoticias(p) {
//Función que imita el comportamiento del Tag "marquee"
new Effect.Move('agrupador', {
x: -3,
y: 0,
mode: 'relative',
duration: 0.1,
afterFinish: function() {
var offSetDistance = $('agrupador').offsetLeft ;
offSetDistance = Math.abs(offSetDistance);
var gettingWidth = $('moverlo').getWidth() ;
if ( offSetDistance >= gettingWidth ) {
Element.setStyle('agrupador', {left: '0px' });
}
MoveNoticias();
}
});
}
I hope you understand what I am trying to do! Thanks!

Try removing the float: left from the li, and adding white-space: nowrap to the 'ul'.
I tried that here: http://jsfiddle.net/76d6p/

Related

Tab Width CSS not working in Firefox and Internet Explorer

I have the following css for tabs,
.columbia-browser-blackberry .ui-tabs .ui-tabs-nav li a, .columbia-browser-
chrome .ui-tabs .ui-tabs-nav li a, .columbia-browser-iemobile .ui-tabs .ui-
tabs-nav li a, .columbia-browser-safari .ui-tabs .ui-tabs-nav li a,
.columbia-browser-moz.ui-tabs .ui-tabs-nav li a
{
padding: .5em 1em;
width: 225px;
word-wrap: initial;
height: 25px;
text-align: center;
display: inline;
}
Html
/**
* Page Tabs Control
* #TODO guerrics: overflowing tabs
*
* #param array pages - array of pages (default: map.values(page.subpages))
* #param str tab - name of the selected tab (default: __request.args.tab)
*/
var pages = $pages ?? map.values(page.subpages);
let pages = [ (p is str) ? wiki.getpage(p) : p foreach var p in pages];
var selectedTab = $tab ?? __request.args.tab;
// find the active tab page
var activeTab = [ tabpage foreach var tabpage in pages where tabpage.name ==
selectedTab ][0];
// no selected tab found, use first tab
if (!activeTab) {
let activeTab = pages[0];
}
<div class="mt-tabs ui-tabs ui-widget ui-widget-content ui-corner-all"
id="tabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-
header ui-corner-all">
foreach(var tabpage in pages) {
<li id=('tab-'..tabpage.name) class=('ui-state-default ui-
corner-top'..(tabpage.name == activeTab.name ? " ui-tabs-selected ui-state-
active " : ""))>
<a href=(page.uri & {tab: tabpage.name})>
tabpage.title ?? "#" .. (__count + 1)
</a><span></span>
</li>
}
</ul>
<div class=("ui-tabs-panel ui-widget-content ui-corner-bottom"..(#pages
> 0 ? "" : "ui-state-empty"))>
if (activeTab) {
var contents = activeTab.contents;
if (contents) {
contents;
} else {
wiki.page(activeTab.path);
}
}
</div>
</div>
It works for Google chrome, but it doesn't work in Mozilla and Internet Explorer. I am trying to giving the tabs a uniform width of 225px.
Any help would be appreciated?
To apply width, set css property 'display' to either 'block' or 'inline-block'.
block: the element will sit in a single line. In such case you may want to set float so links are in the same line;
inline-block; the element will have height, width, etc, and multiple elements will sit in the same line (block).
try with:
display:inline-block
This is how it worked.
body .ui-tabs .ui-tabs-nav li a
{
padding: .5em 1em;
width:225px;
word-wrap: initial;
height: 25px;
text-align: center;
display: inline-block;
}

How do i go to homepage with a click event in angularjs?

I have 3 tabs which are created using li...when I click cancel in addform tab I must redirected to home page..But the add form tab is highlighted even it is redirected to homepage.I want to redirect to home page and home tab must be redirected.I am unable how to do it on click event..
My code is mentioned below :
//when cancel button is clicked
$scope.cancelbtn=function(){
$window.location.href="#Home"
ngDialog.closeAll();
};
//html
<div id="header">
<div id="header_name" style="padding-top:25px"><center><h1 class="hh"><a>Dynamic Creation of Forms</a></h1></center></div>
<div id="nav-masthead" role="navigation">
<ul style="padding-top: 38px;padding-left:113px">
<li >
<span class="glyphicon glyphicon-home">Home</span>
</li>
<li>
<span class=" glyphicon glyphicon-plus-sign ">Add Form</span>
</li>
<li>
View Form
</li>
</ul>
</div>
</div>
<div style="color:#0d7dc1;padding: 51px;padding-left: 120px;"><ng-view></ng-view></div>
//css
#header {
background-image: url(//www.drupal.org/sites/all/themes/bluecheese/images/sprites-horizontal.png);
background-color: #56b3e6;
height:141px;
background-position: 0 -1088px;
}
.hh{
margin-top:0;
}
#nav-header {
overflow:hidden;
font-size:0.923076em;
min-height:1.5em;
}
#header_name a{
background-position: 0 -467px;
background-repeat: no-repeat;
color:white;
text-decoration:none;
height: 63px;
overflow: hidden;
text-indent: -999em;
width: 181px;
}
#nav-masthead{
width:100%;
float:right;
margin-right: 0;
display: inline;
position: relative;
z-index: 1;
min-height: 0.69231em;
}
ul{
list-style: none;
font: inherit;
font-size: 100%;
}
#nav-masthead ul li{
list-style: none;
float: left;
font-size: 0.923076em;
margin-right: 0.615384em;
}
#nav-masthead ul li a {
background-color: #0d7dc1;
border-radius: 10px 10px 0 0;
color: white;
float: left;
padding: 0.416666em .75em 0.416666em 0.615384em;
text-decoration: none;
}
#nav-masthead ul li:hover a {
background-color: white;
color:black;
}
#nav-masthead li a.col {
color: black;
background-color: white;
}
//script
$(document).ready(function() {
$('#nav-masthead li a').click(function() {
$('#nav-masthead li a').removeClass("col");
$(this).addClass("col");
});
});
Can anyone solve this.When I redirected to home page I need to get home highlighted instead of add form.
reference: How to set bootstrap navbar active class with Angular JS?
essentially if you have a MainCtrl that encapsulates everything you'll be able to keep track of which active state is currently being active.
angular.module('app').controller('MainCtrl', ['$scope', '$location', function($scope, $location) {
$scope.isActive = function('viewLocation') { //pass in the current location
return viewLocation === $location.path(); //class becomes active if the pathing is corret
}
}]);
and then have your html include the ng-class calling that function
<li ng-class="{ active: isActive('/home')}">
<span class="glyphicon glyphicon-home">Home</span>
</li>
<li ng-class="{ active: isActive('/add')}">
<span class=" glyphicon glyphicon-plus-sign ">Add Form</span>
</li>
<li ng-class="{ active: isActive('/view')}">
View Form
</li>
unless I'm miss understanding your question, hope it helps.
I have got the answer ..Just to redirect to home page when click eventi have just used the below code.
$scope.cancelbtn=function(){
$('#home').trigger('click');
ngDialog.closeAll();
};
By using above code i have solved it.i am posting my answer because it may helpful to others.
Thank You.

How can I make a fix positioned menu bar?

I would like to style my menu bar Like THIS.
It's fixed to the top of the site when you scroll down and it isn't fixed where it is when the page is loaded.
How can it be done with CSS?
What you're after is a 'sticky navbar/menu'.
The simplest way would be to add the below CSS to your menu/navbar
position:fixed;
top:0px;
That said, for an effect closer to the one you've posted, you'll probably want to look at using some jQuery, e.g.:
$(window).bind('scroll', function() {
if ($(window).scrollTop() > 50) {
$('.menu').addClass('fixed');
}
else {
$('.menu').removeClass('fixed');
}
});
What this does is 'fix' the menu bar to the top of the page once you scroll past a certain point (e.g. 50px) by adding the CSS class 'fixed' to the .menu element, the fixed class would simply be e.g. the CSS above.
There are some nice examples listed here.
Source: Creating a sticky nav css and jquery
HTML
<div id="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Blog</li>
<li>Shop</li>
<li>Contact</li>
</ul>
</div>
<div id="content">
This is some content 0<br/>
This is some content 1<br/>
This is some content 2<br/>
This is some content 3<br/>
This is some content 4<br/>
This is some content 5<br/>
This is some content 6<br/>
This is some content 7<br/>
This is some content 8<br/>
<div id="data" />
</div>
CSS
* {
font-family: Consolas,Sans-serif;
font-size: 10pt;
}
#menu {
position: absolute;
width: 100%;
}
#menu.out {
position: fixed;
}
#menu ul {
margin: 0;
padding: 1em .5em;
list-style: none;
background-color: #fc9;
}
#menu ul li {
display: inline-block;
}
#menu ul li a {
padding: 5px .5em;
}
#content {
background-color: #ebebee;
padding: 4em 1em 1em;
height: 900px;
}
JQuery:
var menu = $("#menu");
var ul = menu.find("ul");
var content = $("#content")[0];
var data = $("#data");
var menuHeight = menu[0].getBoundingClientRect().bottom;
var inView= true;
$(document).scroll(function(evt) {
evt.preventDefault();
var top = content.getBoundingClientRect().top;
var nextInView = top+menuHeight > 0;
if (inView ^ nextInView)
{
data.append("<div>Switching.</div>")
inView = nextInView;
if (inView)
{
menu.removeClass("out");
}
else
{
menu.addClass("out");
ul.hide().slideDown("fast");
}
}
});
Fiddle :Demo
Courtesy : Robert Koritnik
Hope this helps
Happy Coding

Bootstrap drop down cutting off

I am trying to add a dropdown setting menu to my comments section in a project that I've been working on.
The dropdown menu seems to cut itself off and I am not sure why is that the case.
I tried overflow:visible and z-index:999. but none of them seem to work.
This is a basic comment block that I am trying to include a dropdown in
This is the basic code that I am trying to Implement
<div class="media">
<a class="pull-left" href="/user/{{shared_scribble.scribble.user.username}}/"><img class="media-object" src="/img.png/"></a>
<div class="dropdown pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" style="font-size:10px;padding: 4px 8px;">
<b data-icon=""></b> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><i class="icon-pencil"></i> Edit</li>
<li><i class="icon-trash"></i> Delete</li>
<li><i class="icon-ban-circle"></i> Ban</li>
<li class="divider"></li>
<li><i class="i"></i> Make admin</li>
</ul>
</div>
<div class="media-body">
<h4 class="media-heading"><a class="username" href="/user/hi/">Test User</h4>
<p>
Main body of the comment
</p>
</div>
</div>
And this is how my dropdown menu is turning out to be
media CSS
.media,
.media-body {
overflow: hidden;
*overflow: visible;
zoom: 1;
}
.media,
.media .media {
margin-top: 15px;
}
.media:first-child {
margin-top: 0;
}
.media-object {
display: block;
}
.media-heading {
margin: 0 0 5px;
}
.media .pull-left {
margin-right: 10px;
}
.media .pull-right {
margin-left: 10px;
}
.media-list {
margin-left: 0;
list-style: none;
}
This is not an ideal solution as the menu will not scroll with the target element, but I'm doing this for a scrolling data table as a last resort until I can find an alternative:
(function() {
var dropdownMenu;
$(window).on('show.bs.dropdown', function(e) {
dropdownMenu = $(e.target).find('.dropdown-menu');
$('body').append(dropdownMenu.detach());
dropdownMenu.css('display', 'block');
dropdownMenu.position({
'my': 'right top',
'at': 'right bottom',
'of': $(e.relatedTarget)
})
});
$(window).on('hide.bs.dropdown', function(e) {
$(e.target).append(dropdownMenu.detach());
dropdownMenu.hide();
});
})();
This will append the menu to the body and clean it up on hide. I'm using jquery UI for positioning but you can replace it with regular jquery positioning if you don't want to add the heavy dependency. You may also want to alter $(window).on if you only want to do this to a limited selection of dropdowns.
Check whether media class is has overflow:hidden. If so, replace it with overflow: auto or overflow: visible.
Write like this:
.media,
.media-body {
overflow: visible;
}
.media:after,
.media-body:after{
content:'';
clear:both;
display:block;
}
May be that's help you.
I had the same problem. After adding this lines, my dropdown worked just as I expected:
#media (max-width: 767px) {
.table-responsive .dropdown-menu {
position: static !important;
}
}
#media (min-width: 768px) {
.table-responsive {
overflow: visible;
}
}
I found the solution here
NEW METHOD:
Just bring drop down menu out of media class and use a negative margin:
<div class="dropdown pull-right" style="margin-left:-30px">
...
</div>
<div class="media">
...
</div>
Get this quite often on projects I inherit; tends to be a case of one of the parent elements having
overflow:hidden
Once I remove this it seems to work as expected (as long as your design doesn't rely on this property).
Based on #nick answer, this is what I do in Bootstrap 3 without Jquery UI.
let dropdown_toggles = $('.my-table .dropdown-toggle');
dropdown_toggles.each(function (index, elem) {
let dropdownMenu;
let dropdown_toggle = $(elem);
dropdown_toggle.dropdown();
dropdown_toggle.parent().on('show.bs.dropdown', function(e) {
let $target = $(e.target);
let $relatedTarget = $(e.relatedTarget).parent();
dropdownMenu = $target.find('.dropdown-menu');
dropdownMenu.css({
'position': 'absolute',
'z-index': 1,
'top': ($relatedTarget.offset().top + $relatedTarget.height()) + 'px',
/*'left': $relatedTarget.offset().left + 'px',*/ //from left
'left': ($relatedTarget.offset().left - dropdownMenu.width() + $relatedTarget.width()) + 'px', //from right
});
$('body').append(dropdownMenu.detach());
dropdownMenu.css('display', 'block');
});
dropdown_toggle.parent().on('hide.bs.dropdown', function(e) {
$(e.target).append(dropdownMenu.detach());
dropdownMenu.hide();
});
});
This will allow you to set from left or right with position absolute.

z-index css Pop-up box and ie7

I have some div boxes which should show a speech box when on hover. With jQuery and CSS it’s nothing too hard.
However, the popup speech appears under the neighbor div in IE7 — I can not make it to appear under it (see the shots).
I tried to play with z-index at different spots with no success.
FF
alt text http://img134.imageshack.us/img134/5314/63386894.png
IE7
alt text http://img396.imageshack.us/img396/9329/95483890.png
HTML
<div class="boardshot_list">
{% for ... %}
<span class="img_box">
<a href="/site_media/xxx" target="_blank">
<img class="trigger" src="xxx" alt="{{ item.title }}" />
</a>
<div class="container_speech_box popup">
<div class="two">
<b class="tl"><b class="tr"></b></b>
<p>
blabla
</p>
<b class="bl"></b><b class="br"><b class="point"></b></b>
</div>
</div>
</span>
{% endfor %}
</div>
CSS
div.boardshot_list span.img_box {
display:block;
width:220px;
height:180px;
float: left;
margin: 0 10px 10px 0;
position: relative;
}
img.trigger{
border:1px solid #373743;
}
div.popup
{
display: none;
position: absolute;
z-index: 50;
}
/* POPUP rounded box */
.container_speech_box div:after {content: "."; display: block; height:11px; clear:both; visibility:hidden;}
.container_speech_box div {width:300px; height:auto; font-family:verdana; font-size:11px;}
b.tl {display:block; width:300px; height:8px; font-size:1px;}
b.tr {display:block; width:292px; height:8px; font-size:1px; float:right;}
b.bl {display:block; width:8px; height:8px; font-size:1px; float:left;}
b.br {display:block; width:292px; height:8px; font-size:1px; float:right; position:relative;}
b.point {display:block; font-size:1px; width:25px; height:14px;}
.container_speech_box div p {padding:8px; margin:0; border:3px solid #4f5b69; border-width:0 3px; text-align:justify;}
div.two b.tl {background:url(/site_media/images/top_left2.gif) top left no-repeat;}
div.two b.tr {background:url(/site_media/images/top_right2.gif) top right no-repeat;}
div.two p {background:#fff;}
div.two b.bl {background:url(/site_media/images/bottom_left2.gif) top left no-repeat;}
div.two b.br {background:url(/site_media/images/bottom_right2.gif) top right no-repeat;}
div.two b.point {background:url(/site_media/images/point2.gif) top left no-repeat; margin:5px 0 0 125px;}
/* end popup table */
div.boardshot_list {
width: 700px;
clear: left;
min-height: 80px;
}
div.boardshot_list .memo_id {
padding-left: 10px;
position: relative;
float:right;
color:#60564d;
font-size: 25px;
padding-top: 20px;
width: 50px;
top: 30px;
left: 10px;
font-family:"Palatino Linotype","Book Antiqua",Palatino,FreeSerif,serif;
}
div.boardshot_list.even {
background-color: #f3f5f6;
}
div.boardshot_list .title span{
color: #bbb;
font-weight: normal;
}
div.boardshot_list .img img {
border:1px solid #373743;
}
JS
<script type="text/javascript">
$(document).ready(function(){
$('.img_box').each(function () {
// options
var distance = 10;
var time = 250;
var hideDelay = 50;
var hideDelayTimer = null;
// tracker
var beingShown = false;
var shown = false;
var trigger = $('.trigger', this);
var popup = $('.popup', this).css('opacity', 0);
// set the mouseover and mouseout on both element
$([trigger.get(0), popup.get(0)]).mouseover(function () {
// stops the hide event if we move from the trigger to the popup element
if (hideDelayTimer) clearTimeout(hideDelayTimer);
// don't trigger the animation again if we're being shown, or already visible
if (beingShown || shown) {
return;
} else {
beingShown = true;
// reset position of popup box
popup.css({
top: -10,
left: 20,
display: 'block' // brings the popup back in to view
})
// (we're using chaining on the popup) now animate it's opacity and position
.animate({
top: '-=' + distance + 'px',
opacity: 0.9
}, time, 'swing', function() {
// once the animation is complete, set the tracker variables
beingShown = false;
shown = true;
});
}
}).mouseout(function () {
// reset the timer if we get fired again - avoids double animations
if (hideDelayTimer) clearTimeout(hideDelayTimer);
// store the timer so that it can be cleared in the mouseover if required
hideDelayTimer = setTimeout(function () {
hideDelayTimer = null;
popup.animate({
opacity: 0
}, time, 'swing', function () {
shown = false;
popup.css('display', 'none');
});
}, hideDelay);
});
});
});
</script>
I think this is due to a z-index bug in Internet Explorer. Positioned elements (i.e. elements with a position other than static) establish their own stacking context.
http://www.quirksmode.org/bugreports/archives/2006/01/Explorer_z_index_bug.html
In my experience, it’s as if all your div.boardshot_list span.img_box have a z-index of 0, and elements inside each div.boardshot_list span.img_box have a z-indexes of 0.1, 0.2 and so on, instead of 1 and 2.
You should be able to fix the issue by setting the z-index of the span.img_box containing the visible pop-up to 1, like this:
// reset position of popup box
popup.css({
top: -10,
left: 20,
display: 'block' // brings the popup back in to view
})
$(this).css('z-index', '1');
Don’t forget to reset it to 0 when the pop-up disappears.
It's probably because of conflict of multiply classes (.container_speech_box and .popup) style resolution in different browsers. Try to wrap .popup div around the .container_speech_box.

Resources