twitter bootstrap issue : Right align the caret in the dropdown header - drop-down-menu

I have an issue with the right alignment of the caret. Using .pull-right in the span makes it go to the top right corner.
How can I make it vertically centered again ?
I also would like to align the text to the left
http://www.bootply.com/r8x7g5Bw5R
<div class="btn-group cust-dropdown">
<button type="button" class="btn btn-default dropdown-toggle cust-dropdown" data-toggle="dropdown"><span class="caret pull-right"></span><span>test</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>test</li>
<li>tes2</li>
<li>test3</li>
</ul>
</div>
and the CSS
.cust-dropdown {
width: 200px;}

.caret {
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 8px solid #fff;
left: 90%;
top: 45%;
position: absolute;
}
Using position absolute and a percentage top and left I was able to right align my caret within the dropdown. Works in Chrome, IE, and FF.
EDIT
Previous code will work but changes the style of the caret. If you just want to reposition it maintaining its style, just extend Bootstrap's .caret class:
.caret {
position: absolute;
left: 90%;
top: 45%;
}

A much simpler solution exists for this problem. This style should look the most natural and be the most responsive to all usages as it does not depend on any predetermined layout (other than default bootstrap styles).
.dropdown > .btn > .caret {
float: right;
margin: 6px 0;
// if you are using Less, the you can reuse the actual vertical padding
// margin: #padding-base-vertical 0;
}

Just interchange the caret and span blocks in HTML:
HTML
<div class="btn-group cust-dropdown">
<button type="button" class="btn btn-default dropdown-toggle cust-dropdown" data-toggle="dropdown"><span id= "titl">test</span><span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>test</li>
<li>test 2</li>
<li>test 3</li>
</ul>
</div>
CSS
.cust-dropdown {
width: 200px;
}
#titl {
padding-right: 10px;
}
You can align the text more to the left by adding more padding-right.

Related

bootstrap3 - caret reverse on click in navbar-nav

I'm using bootstrap 3, and I found few lines of css, that work great, making the caret to reverse (upside-down) on click.
.navbar-nav .open > a > b.caret {
border-top: none;
border-bottom: 4px solid;
}
For your reference, this is my (pretty standard) dropdown:
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Some Title Text <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>Some Submenu text</li>
<li>Some Submenu text</li>
</ul>
</li>
</ul>
Why is this happening? I would like your help to deeply understand it.
Thank you!
Bootstrap caret uses a popular trick to draw triangle in CSS.
You can see it HERE
CSS code for top and bottom arrows (triangles):
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid black;
}

Kendo Multiselect change the zindex of dropdown list div

I am using Kendo Multiselect control. I wish to change the Z-index of the control. Here is the rendered html markup from the firebug window.
<div class="k-animation-container" style="width: 383px; height: 124px; margin-left: -10px; padding-left: 10px; padding-right: 10px; padding-bottom: 15px; overflow: hidden; display: none; position: absolute; top: 237.4px; z-index: 10002; left: 275.4px; box-sizing: content-box;">
<div class="k-list-container k-popup k-group k-reset" id="selInvestors-list" data-role="popup" style="height: auto; display: none; font-size: 12px; font-family: Arial,Helvetica,sans-serif; font-stretch: normal; font-style: normal; font-weight: 400; line-height: 15.2px; width: 377.2px; transform: translateY(-123px); position: absolute;">
<ul class="k-list k-reset" unselectable="on" style="overflow: auto; height: auto;" tabindex="-1" role="listbox" aria-hidden="true" id="selInvestors_listbox" aria-live="polite">
<li class="k-item" unselectable="on" data-idx="2" role="option" tabindex="-1">Client</li>
<li class="k-item" unselectable="on" data-idx="3" role="option" tabindex="-1">Employees</li>
<li class="k-item" unselectable="on" data-idx="4" role="option" tabindex="-1">Other</li>
</ul>
</div>
The jquery code under the Dom ready event is :-
$("#selInvestors").kendoMultiSelect({
dataTextField: "text",
dataValueField: "bitwiseval",
dataSource: invJsonObj
});
var selinvCtl = $("#selInvestors").data("kendoMultiSelect");
selinvCtl.bind("open", function (e) {
//console.log("open event handler");
e.sender.list.closest(".k-animation-container").css('z-index', '90');
});
The problem is every time the dropdown opens it goes back to the z-index value of "10002". I want to set the z-index to "90" every time the dropdown opens or when the dropdown remained open.
Please suggest the soln.
The problem is that the first time you open the list, the k-animation-container does not yet exist, so you cannot set the z-index. On consequent opens, the KendoUI framework always resets the z-index to 1002.
I guess one workaround is for you set set the z-index after a small delay so you are sure the container is there and that KendoUI is done messing with the z-index:
var selinvCtl = $("#select").data("kendoMultiSelect");
selinvCtl.bind("open", function (e) {
setTimeout(setZIndex90, 200, e);
});
function setZIndex90(event) {
event.sender.list.closest(".k-animation-container").css('z-index', '90');
}
In this example I have introduced a 200 millisecond delay.
DEMO

Images on nav bar before each link

Right, so I have made a navigation bar and I want to add images before each link, I know I can use a.header:before but I need different images for each link, a house for home, spanner for spec and so on. What is the simplest way of doing this? Is there a way without creating a div for each one and styling them individually?
For a preview of the page so far with the nav - http://zimxtrial.ukbigbuy.com/
One more thing - here is part of the css:
#header-nav {
background-color: #FFFFFF;
height: 80px; height: 8.0rem;
width: 100%;
position: absolute;
top: 50px;
}
.header-nav-center {
height: 80px; height: 8.0rem;
text-align: center;
position: relative;
top: 0px;
width: 500px; width: 50.0rem;
margin-left: auto;
margin-right: auto;
}
.header-nav-center ul {
margin: 0;
}
.header-nav-center ul li {
list-style: none;
margin: 0 35px 0 0;
display: inline;
}
a.header {
line-height: 80px; line-height: 8.0rem;
font-size: 17px; font-size: 1.7rem;
}
And HTML:
<div id="home">
<div id="header-nav">
<div id="hr-nav-top-container">
<hr class="nav" />
</div>
<div id="logo"></div>
<div class="header-nav-center">
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li><a class="header" href="#features">Features</a>
</li>
<li><a class="header" href="#specification">Specification</a>
</li>
<li><a class="header" href="#contact-us">Contact Us</a>
</li>
</ul>
</div>
<div id="pre-order"></div>
<div id="hr-nav-bottom-container">
<hr class="nav" />
</div>
</div>
</div>
Can I add something like:
a.header.home:before {
background: url('../images/home-logo.png') center center no-repeat;
}
Not that exactly but something like it?
You could make ids for each link and add the ids to the desired link img

How to make a row of three images responsive

Using Twitter Bootstrap 3, I have a container, three div place holders, and three images that fill as links each floated side by side and taking up the entire row: When I minimize the screen to make it responsive, I only see the first image (the second two dissapear). What steps would I have to take to make sure that each image becomes responsive and sits one below the other at the minimize dmobile display screen.
Please Note: Each Img. already has class="img-responsive" applied to it.
HTML:
<!--Wide Display Container -->
<div class="wide-display">
<div id="firstholder">
<a href="home.html" title="Home" class="imglink"><img src="/images/slide2.JPG" alt="City Lights Image" class="img-responsive" id="electricone">
<div class="item1">
<h1 class="slickfont1" >First Title</h1>
</div>
</a>
</div>
<div id="secondholder">
<a href="office.html" title="Office" class="imglink"><img src="/images/ant.JPG" alt="City Lights Image" class="img-responsive" id="electrictwo">
<div class="item1">
<h1 class="slickfont1" >Second Title</h1> </div></a>
</div>
<div id="thirdholder">
<a href="reviews.html" title="Locations" class="imglink"><img src="/images/family.JPG" alt="City Lights Image" class="img-responsive" id="thirdelectric">
<div class="item1">
<h1 class="slickfont1" > Third Title</h1>
</div>
</a>
</div>
</div><!-- Wide Display Container -->
CSS:
.wide-display {
min-width:33%;
position: relative;
width: 100%;
height:100%;
margin-top:6px;
overflow: hidden;
height:366px;
}
/*! First img Holder */
#firstholder {
width: 449px;
height: 100%;
float:left;
display:inline-block;
margin-left:1px;
margin-right:0px;
}
.item1 {
width: 24%;
margin: auto;
position:relative;
}
#secondholder {
width: 450px;
height: 100%;
float:left;
display:inline-block;
margin-right:0px;
}
#thirdholder {
width: 449px;
height: 100%;
float:left;
display:inline-block;
}
You have to create Bootstrap Grid to make it work. You can just read the documentation here: http://getbootstrap.com/css/ it's pretty easy to understand. The divs that wrap you images need to have grid classes applied to them.

Pop up logout button

In my application, logging out is a two way process. When you click on the Logout link on the main screen, it opens up a pop-up for confirmation of logout.
Now, on pop-up, there are two button ( 'Logout' and 'Cancel'). The problem is that I am not able to click on either of them.
Using Firebug console, I confirmed that the XPath which I am using is correct. But when using the same Xpath in webdriver, it's not able to locate the object.
Xpath of the button on the pop-up : //div[3]/div/div/div[2]/div/a/span
Code which I am trying :
IWebElement LogoutButton = WebDriver.FindElement(By.XPath("//div[3]/div/div/div[2]/div/a/span"));
LogoutButton.Click();
Is there any specific method to use here ?? Please let me know.
cheers
EDIT*
<div id="ext-comp-1084" class="x-window x-layer x-window-default x-closable x-window-closable x-window-default-closable x-popup" tabindex="-1" style="opacity: 1; width: 250px; height: 145px; right: auto; left: 755px; top: 147px; z-index: 19000;">
<div id="ext-comp-1084_header" class="x-window-header ext-header ext-header-horizontal x-docked x-unselectable x-window-header-default x-horizontal x-window-header-horizontal x-window-header-default-horizontal x-top x-window-header-top x-window-header-default-top x-docked-top x-window-header-docked-top x-window-header-default-docked-top" style="width: 250px; right: auto; left: 0px; top: 0px;">
<div id="ext-comp-1084-body" class="x-window-body x-window-body-default x-closable x-window-body-closable x-window-body-default-closable x-window-body-default x-window-body-default-closable" style="width: 250px; left: 0px; top: 52px; height: 49px;">
<div id="toolbar-1086" class="x-toolbar x-docked x-toolbar-default x-docked-bottom x-toolbar-docked-bottom x-toolbar-default-docked-bottom x-box-layout-ct" style="width: 250px; right: auto; left: 0px; top: 101px;">
<div id="toolbar-1086-innerCt" class="x-box-inner " role="presentation" style="width: 250px; height: 44px;">
<div id="toolbar-1086-targetEl" class="x-box-target" style="width: 250px;">
<div id="tbspacer-1087" class="x-toolbar-spacer x-box-item x-toolbar-item x-toolbar-spacer-default" style="right: auto; left: 0px; margin: 0px; width: 50px; top: 22px;"></div>
<div id="button-1088" class="x-btn green x-exclude x-unselectable x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" style="border-width: 1px; width: 100px; right: auto; left: 50px; margin: 0px; top: 8px;">
<div id="button-1088-btnWrap" class="x-btn-wrap" unselectable="on">
<a id="button-1088-btnEl" class="x-btn-button" tabindex="0" unselectable="on" hidefocus="on" role="button">
<span id="button-1088-btnInnerEl" class="x-btn-inner x-btn-inner-center" unselectable="on">Logout</span>
<span id="button-1088-btnIconEl" class="x-btn-icon-el " style="" unselectable="on" role="img"></span>
</a>
</div>
</div>
<div id="button-1089" class="x-btn gray x-exclude x-unselectable x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" style="border-width: 1px; width: 80px; right: auto; left: 160px; margin: 0px; top: 8px;">
<div id="button-1089-btnWrap" class="x-btn-wrap" unselectable="on">
<a id="button-1089-btnEl" class="x-btn-button" tabindex="0" unselectable="on" hidefocus="on" role="button">
<span id="button-1089-btnInnerEl" class="x-btn-inner x-btn-inner-center" unselectable="on">Cancel</span>
<span id="button-1089-btnIconEl" class="x-btn-icon-el " style="" unselectable="on" role="img"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
1) First save the instance of main window using below code
String mainWindow = driver.getWindowHandle();
2) //code to click on the Logout link on the main screen
3) then switch webdriver control to pop-up using below code
for(String childWindow : driver.getWindowHandles()){
driver.switchTo().window(childWindow);
}
4) //code to click on pop-up, ( 'Logout' and 'Cancel').

Resources