I have created bootstrap menu items and kept FLIP option beside that.
FIDDLE
Here issue is that FLIP should be just beside the box, but it is appearing downside?
HTML:
<div class="magic-container">
<div class="input-group">
<input type="text" class="typeahead form-control" placeholder="Select category ..." />
<ul class="dropdown-menu">
<li id="one">Sports</li>
<li role="presentation" class="divider"></li>
<li id="two">Entertainment</li>
<li role="presentation" class="divider"></li>
<li id="three">Politics</li>
<li role="presentation" class="divider"></li>
<li id="four">Business</li>
<li role="presentation" class="divider"></li>
<li id="four">Travel</li>
<li role="presentation" class="divider"></li>
<li id="four">Celebrity</li>
<li></li>
</ul>
<span class="flip">
<span class="dropDownFlip">
FLIP
</span>
</span>
</div>
</div>
Your input is having a width of 100% being applied to it. It is being applied from the bootstrap.min.css file. By adding the following to your css it fixes your issue:
.input-group .form-control {
width: auto;
}
Here is your jsFiddle updated.
Update: Since this is a change to an existing class and could possibly affect elements elsewhere on your page/site, you could create a new class for this particular instance. Something like this would work:
.input-group .floatLeft {
float: left !important;
width: auto;
}
and just add the class floatLeft to your input.
Try to add following styles in you stylesheets
.magic-container .input-group input {
float: left;
margin-right: 2%;
width: 70%;
}
.flip {
float: left;
}
Related
I'am trying to display messages with the help of 'li' tag line by line .The main motive is to display our messages on right side whereas others on the left side in a react Chat app
but the problems is whenever I try with float left or float right , all the elements come into the same line like this
My react chat styling code is this
{this.state.chats.map(chat => (<div key={chat.timestamp}>
{this.state.user.uid === chat.uid ?(
<li className=" self" style={{listStyleType:"none",overflow:'hidden',marginLeft: 2 +'px',float:'right',display:'inline-block',
backgroundColor:"whitesmoke",margin:2 + "em",padding:13+'px',width:'max-content',borderBottomLeftRadius:11+'px',
borderBottomRightRadius:11+'px',borderTopLeftRadius:11+'px'}}>
<div className="message text-dark">{chat.content} </div>
</li>
):(
<li className="other" style={{listStyleType:"none",overflow:'hidden',marginLeft: 2 +'px',float:'left',display:'inline-block',
backgroundColor:"blanchedalmond",margin:2 + "em",padding:13+'px',width:'max-content',borderBottomLeftRadius:11+'px',
borderBottomRightRadius:11+'px',borderTopRightRadius:11+'px'}}>
<div className="message text-dark">{chat.content}</div>
</li>
)}
</div>
))}
Edit !: after floating individual div
.self {
background: orange;
float: right;
clear: both;
}
.other {
background: blue;
float: left;
clear: both;
}
<ul>
<li class="self">message</li>
<li class="self">message</li>
<li class="self">message</li>
<li class="self">message</li>
<li class="other">message</li>
<li class="other">message</li>
<li class="other">message</li>
<li class="self">message</li>
</ul>
https://developer.mozilla.org/en-US/docs/Web/CSS/clear
Check out the clear property for floated elements.
Flexbox solution:
.left {
display: flex;
justify-content: flex-start;
}
.right {
display: flex;
justify-content: flex-end;
}
<ul>
<li class="left">
Others message
</li>
<li class="right">
Your message
</li>
</ul>
Solution 2
Try <li> take up the whole line, and put float: left/right to the inner <div>
Something like: https://jsfiddle.net/L1g6wx34/
.left {
float: left;
}
.right {
float: right;
}
<ul>
<li>
<div class="left">
Others message
</div>
</li>
<li>
<div class="right">
Your message
</div>
</li>
<li>
<div class="right">
Your message
</div>
</li>
</ul>
I am trying to indent the text from an inline block on safari. It only indents in chrome.
I have tried using margin left. This works in chrome but in safari i have to adjust the margin-left to another number for them to look the same.
I tried the text-indent and the inline-block is not wrapping properly now.
html
<nav>
<ul>
<li><a href="#" >Home</a></li>
<li type="checkbox" class="sub">
<input type="checkbox" />
<a href="#" >Profile</a>
<!-- Begin-->
<ul class="submenu">
<li >
<a target = "box">Profiles</a>
</li>
</ul>
</li>
<!-- end-->
<li class="sub">
<input type="checkbox" />
<a href="#" >Logs</a>
<!-- Begin-->
<ul class="submenu">
<li >
<a target = "box" >View Logs</a>
</li>
<li >
<a target = "box" >Testing a long test</a>
</li>
</ul>
</li>
</li>
</ul>
</nav>
CSS in chrome
nav .submenu a {
*zoom: 1;
*display: inline;
display: inline-block;
max-width: 122px;
margin-left: 55px;
padding: 3px 1px 3px 0px;
}
CSS in safari
nav .submenu a {
*zoom: 1;
*display: inline;
display: inline-block;
max-width: 122px;
margin-left: 65px;
padding: 3px 1px 3px 0px;
}
I tried putting important on the variables to see anything overrides it too and that didn't help them look the same.
I also tried
text-indent: 50px;
Make a table with no content and put it ahead of your text.
<table>
<tbody>
<tr>
<td width="65px"> <!--this is the indent, don't forget to style it so it becomes invisible.--></td>
</tr>
</tbody>
</table>
Am New to Asp.net and CSS.
I Need to Show Horizontal Menu only image like this
image 1 image 2 image 3 image 4
So I tried like this
CSS
#UlIcon
{
height: 100%;
list-style:list-style-image;
text-align:center;
padding-left: 5px;
}
#UlIcon li { display:inline; width : 100px; height:100%;}
#LiNew
{
list-style-image:url(/IMG/New.png);
}
#LiSave
{
list-style-image:url(/IMG/Save.png);
}
#LiDelete
{
list-style-image:url(/IMG/Delete.png);
}
#LiLog
{
list-style-image:url(/IMG/New.png);
}
#Padding-right {padding-right:15px;}
ASP.NET CODE
<div id="DivMenuRight">
<ul id="UlIcon">
<li id="LiNew"></li>
<li id="LiSave"></li>
<li id="LiDelete"></li>
<li id="LiLog"></li>
</ul>
</div>
But it shows empty. If I Remove display: inline in li css, the image shows vertically in center of the div. What am doing wrong here?
How do I get the solution?
Am using Visual Studio 2008 and CSS2.1
the css list-style-image will place an image next to each point or listed text. it act as an image bullet
I am of the opinion you would like to have this
<div id="DivMenuRight">
<ul id="UlIcon">
<li id="LiNew">
<img src="link1">
</li>
<li id="LiSave">
<img src="link2">
</li>
<li id="LiDelete">
<img src="link3">
</li>
<li id="LiLog">
<img src="link4">
</li>
</ul>
</div>
then you can use css to display all list elements inline-block
example display:inline-block
here is a snippet
img {
display:inline-block;
width:50px;
height:50px;
}
li {
display:inline-block;
}
<div id="DivMenuRight">
<ul id="UlIcon">
<li id="LiNew">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTCjDQxLj9LSCLsCI2iCDEawZVlJ7tlRuBQDHenXo_KaFhdTUiTGw">
</li>
<li id="LiSave">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQqyRrA_-5TM0vpRU8BcTPFpGubyzgHGtvE9FQzpnVMPnKnoZwkmQ">
</li>
<li id="LiDelete">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcShZ_bYswgHlQLrUn8egsNTTZn5nCmSz1NcFmvtUzujpZhrBflUiQ">
</li>
<li id="LiLog">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTCjDQxLj9LSCLsCI2iCDEawZVlJ7tlRuBQDHenXo_KaFhdTUiTGw">
</li>
</ul>
</div>
I have a solution for my problem, but it doesn't seem right. I want to know what's going on.
Nested list item's background colour doesn't extend to the bottom even though there's no margin on it (see the gap below the blue background in the screen shots). The paragraph inside does have a margin. But I've tried to reproduce this outside of my app (which uses Bootstrap) and I can't. In Firebug I tried turning off all CSS except that which was necessary to show the problem (i.e., the background-color and border -- see 2nd image), but it makes no difference. Seen in Chrome and Firefox.
The fix is either adding bottom padding or overflow-y:auto; to the inner list item. But why? Has anyone encountered something like this?
I can't post all the code here, but the HTML at least is something like this:
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
[Update] Here is a simplified, non-Bootstrap version. Why no gaps in this one?
ul {
width: 300px;
border: 1px solid red;
float: left;
}
li.sub {
border: 1px solid green;
background-color: yellow;
padding: 8px 8px 0;
}
p { margin:10px; /* no gaps with or without this */ }
<ul>
<li><p>item 1</p>
<ul>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
<li class="sub">
<div>
something
</div>
<p>
stuff
</p>
</li>
</ul>
</li>
<li>thing
<ul>
<li class="sub">
nuther
</li>
</ul>
</li>
</ul>
The spacing is occurring because of the margins in the p elements inside the lis, specifically the bottom margin.
This behavior is defined as 'collapsing margins'. More info here: http://www.w3.org/TR/CSS2/box.html#collapsing-margins
You can see this by setting them to 0.
.notification-new p{
margin:0;
}
Live example: http://www.bootply.com/wlfIl3RziC
Full code below:
.notification-new {
background-color:red;
}
.notification-new p{
margin:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown open">
<ul class="dropdown-menu notification-list">
<li class="notification-new">
<div class="text-muted">01/13/2015</div>
<p>Check out the new features coming to the 2015.1 release here!</p>
</li>
<li class="notification-new">
<div class="text-muted">12/24/2014<button class="close" type="button"><span class="sr-only">Close</span></button></div>
<p>Upcoming server maintenance scheduled for 11:00pm PST.</p>
</li>
</ul>
</li>
</ul>
I have a problem. It might look simple, but I can't fix this.
I have a menu, that shows me 10 items. The 9th item is not aligned in right way, cause has 2 lines of text.
How can I fix this?
JSFIDLE
HTML:
<ul style="list-style:none; width: 615px;">
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=34&preview=1">DFC Portugal</a>
</li>
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=30&preview=1">Processo DFC</a>
</li>
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=72&preview=1">Como Participar</a>
</li>
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=70&preview=1">Calendário</a>
</li>
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=71&preview=1">Regulamento</a>
</li>
<li style="display: inline-block;"><a class="butao" href="http://www.ahighplay.org/pt/gca/index.php?id=26&preview=1">FAQ's</a>
</li>
<li style="display: inline-block;">Vídeos
</li>
<li style="display: inline-block;">Notícias
</li>
<li style="display: inline-block;">Parceiros / Patrocinadores
</li>
<li style="display: inline-block;">Contactos
</li>
Add this settings to make the buttons stay on the same line.
ul li {
vertical-align: middle;
}
jsFiddle Demo
Further more, is not advisable to use inline styles (and it repeats itself on every list item). You should move that setting to the CSS, so your code would be:
ul li {
vertical-align: middle;
display: inline-block;
}