I create a popup via javascript, below is the rendered html. I would like to have a headingrow containing the heading("Preisrechner") and both of the icons you see below. I can't really adjust them so that they are in one row. What should I do to get one row with heading and icons?
FIDDLE
<div style="display: table; top: 51px; right: 0px;" id="quickrechner" class="popup-wrapper">
<div class="my-popup-box">
<div class="my-popup-heading"><h5>Preisrechner</h5>
<div class="headingIcons">
<ul>
<li><i class="ion-ios-navigate-outline"></i></li>
<li><i class="ion-ios-close-empty"></i></li>
</ul>
</div>
</div>
<div class="my-popup-content">
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="col-md-4"><label for="e">EK - Preis:</label></div>
<div class="col-md-8"><input class="buyIn" id="e" type="text"></div>
</div>
<div class="col-md-6 col-xs-12">
<div class="col-md-4"><label for="d">EK - Preis:</label></div>
<div class="col-md-8"><input class="buyIn" id="d" type="text"></div>
</div>
</div>
</div>
</div>
</div>
</div>
.popup-wrapper{
display:none;
position:absolute;
top:51px;
background:#bdbdbd;
z-index:10
}
.my-popup-box{
display:table-cell;
line-height:18px
}
.my-popup-heading{
width:100%;
padding-left:5px;
float:left;
}
.my-popup-heading i{
font-size:1.1em;
font-weight:700;
margin:0 8px;
position: relative;
float:right;
}
.my-popup-heading .heading-icons{
position:absolute;
right:10px
}
.my-popup-content{
margin-left:auto;
margin-right:auto;
width:100%;
padding:9px
}
DESIRED RESULT:
You seem to be using bootstrap, so one solution would be this:
<div class="my-popup-heading"><h5 class="pull-left">Preisrechner</h5>
<div class="headingIcons">
<ul class="list-inline pull-right">
<li><i class="ion-ios-navigate-outline"></i></li>
<li><i class="ion-ios-close-empty"></i></li>
</ul>
</div>
</div>
In basic you can give the icons and the heading different floats to achieve you desired outcome. .pull-right and .pull-left are the bootstrap classes to give floats.
Updated Fiddle
I created a JSfiddle with the simple changes you desired.
Here are the critical CSS changes:
.my-popup-heading h5{
display: inline-block;
width: 45%;
float: left;
}
.headingIcons ul li{
display: inline;
}
.my-popup-heading .heading-icons{
display: inline-block;
float:right;
width:45%;
}
In order to have block level elements (<h5>, <ul>) on the same line, you have to use a display type such as inline or inline-block. And to have <li> on the same line, you have to use display:inline.
If I misunderstood, comment below.
Try it with:
ul {
float: right;
}
h5 {
float: left;
}
You should wrap them of course. Otherwise they will apply to all h5 and ul tags...
Related
I need to have two divs next to each other. The left div has a width of 75% and the right 25%. The content of the left div must align left and the right div aligns right.
So this is what I did:
<div class="header_menu">
<div class="links">
Home Contact
</div>
<div class="social_media">
Contact twitter linkedin
</div>
</div>
The css:
.header_menu{
border-bottom:1px solid #CCC;
}
.links{
width:75%;
display:inline;
}
.social_media{
width:25%;
display:inline;
}
I tried to add a float:left; and float:right; but then the border isn't placed at the bottom anymore.....???
M.
Take a look into this jsfiddle that should work for you:
https://jsfiddle.net/cmkgn4fg/4/
HTML-Code:
<div class="header_menu">
<div class="links">
Home Contact
</div>
<div class="social_media">
Contact twitter linkedin
</div>
<div class="clearfix"></div>
</div>
CSS-Code:
.header_menu{
border-bottom:1px solid #CCC;
width:100%;
}
.links{
width:75%;
float:left;
text-align:left;
}
.social_media{
width:25%;
float:left;
text-align:right;
}
.clearfix{
clear:both;
}
You were almost there. inline-block is the one to use.
As inline elements has a white space, which will make them slightly bigger than 75% / 25% and therefore break them into 2 lines as they would exceed 100%, margin-right: -4px; is one way to fix that and make them both stay on 1 line.
Note, the -4px is based on the set font and might need to be adjusted, so here are a more options:
How do I remove the space between inline-block elements?
Stack snippet
.header_menu{
border-bottom:1px solid #CCC;
}
.links{
display: inline-block;
margin-right: -4px;
width:75%;
text-align: left;
}
.social_media{
display: inline-block;
margin-right: -4px;
width:25%;
text-align: right;
}
<div class="header_menu">
<div class="links">
Home Contact
</div>
<div class="social_media">
Contact twitter linkedin
</div>
</div>
Inline elements don't respond to width and height styles, which is why you are running into this issue.
Remember when floating divs, you will need a clearfix. You can read about clearfixes here
<div class="header_menu clearfix">
<div class="links">
Home Contact
</div>
<div class="social_media">
Contact twitter linkedin
</div>
</div>
Then your CSS.
.header_menu{
border-bottom:1px solid #CCC;
}
.links{
width:75%;
float:left;
}
.social_media{
width:25%;
float:right;
}
The rule display: inline; ignores height and width, as the element is now an inline level element (as in it should be treated as part of text/content) but with the display properties table and table-cell you can achieve the layout you require:
<div class="header_menu">
<div class="links">
Home Contact
</div>
<div class="social_media">
Contact twitter linkedin
</div>
</div>
And the CSS:
.header_menu{
border-bottom:1px solid #CCC;
display: table;
}
.links{
width:75%;
displaY: table-cell;
}
.social_media{
width:25%;
display:table-cell;
}
This forces table-like behavior onto the elements but also keeps the styling options of the HTML elements you're using.
Example on jsFiddle.
try this :
<div class="header_menu"
<div class="links">
Home Contact
</div>
<div class="social_media clear">
Contact twitter linkedin
</div>
</div>
and in your css file :
.header_menu{
border-bottom:1px solid #CCC;
}
.links{
width:75%;
display:inline-block;
float: left;
clear: both;
background-color: red;
}
.social_media{
width:25%;
float: right;
display:inline-block;
background-color: orange;
}
the colors bck is for you to see the layout clearly ! hope this would help
I'm trying align two tables side by side in a floated left div. I think I've got how to horizontally align divs in general with floats but in my example below, once I create 3 columns, all floated left, I can't get the two tables in the 3rd column in the div.nestedHorizontalTables to display side by side. I tried display:inline-block but they still keep stacking vertically.
html
<div class="main-content">
<div class="column1">
<table>table1</table>
</div>
<div id="column2">
<!--I want a group of 4 vertical pie charts here-->
<div id="pie1"></div>
<div id="pie2"></div>
<div id="pie3"></div>
<div id="pie4"></div>
</div>
<div id="column3">
<div class="nestedHorizontalTables">
<table id="tab2">table2</table>
<table id="tab3">table3</table>
</div>
<table>Table4</table>
<div class="nestedHorizontalPieAndTable">
<table>table5</table>
<div id="pie6"></div>
</div>
</div>
</div>
css
#column1{
float:left;
width:40%;
}
#column2{
float:left;
width:20%;
}
#column3{
float:left;
width:40%;
}
.nestedHorizontalTables{
display:inline-block;
}
#tab2{
width:80%;
}
#tab3{
width:20%;
}
thanks
.main-content
{
margin:0;
padding:0;
float:left;
width:100%;
}
.column1 {
margin:0;
float: left;
width: 40%;
}
#column2 {
margin:0;
float: left;
width: 20%;
}
#column3 {
margin:0;
float: left;
width: 40%;
}
.nestedHorizontalTables {
display: inline-block;
}
#tab2 {
width: 80%;
}
#tab3 {
width: 20%;
}
<div class="main-content">
<div class="column1">
<table>table1</table>
</div>
<div id="column2">
<!--I want a group of 4 vertical pie charts here-->
<div id="pie1">hello</div>
<div id="pie2"></div>
<div id="pie3"></div>
<div id="pie4"></div>
</div>
<div id="column3">
<div class="nestedHorizontalTables">
<table id="tab2">table2</table>
<table id="tab3">table3</table>
</div>
<table>Table4</table>
<div class="nestedHorizontalPieAndTable">
<table>table5</table>
<div id="pie6"></div>
</div>
</div>
</div>
You may try this
If you just want the two tables inside nestedHorizontalTables to be displayed side by side, add float:left to both.
#tab2 {
width:80%;
float:left;
}
#tab3 {
width:20%;
float:left;
}
Here is a jsFiddle to help you.
I am having difficulties in understanding the nature of table and table-cell when used in css.
Consider the following: http://jsfiddle.net/dd7h7/3/.
HTML
<div class="widget">
<div class="button">
<div class="content">
<div class="icon">A</div>
<div class="label">ABC</div>
</div>
</div>
<div class="button">
<div class="content">
<div class="icon">B</div>
<div class="label">ABCDEF</div>
</div>
</div>
<div class="button">
<div class="content">
<div class="icon">C</div>
<div class="label">ABCDEFGHI</div>
</div>
</div>
</div>
CSS
.widget {
display:block;
margin:0px;
padding:0px;
}
.button {
display:inline-block;
border:1px solid red;
margin:0px;
padding:0px;
}
.content {
display:table;
width:100%;
height:100%;
margin:0px;
padding:0px;
border-spacing:0;
border-collapse:collapse;
}
.icon {
display:table-cell;
width:15px;
height:15px;
margin:0px;
padding:0px;
vertical-align:middle;
text-align:center;
}
.label {
display:table-cell;
margin:0px;
padding:0px;
padding-left:3px;
vertical-align:middle;
}
Im trying to make a widget containing some buttons, that are positioned alongside each other. But I don't understand where the space between the red boxes comes from. How do I get rid of it?
Thanks
Inline elements (in your case the .button divs) are sensitive to white space, you can get rid of that space in a variety of ways, including:
Removing the space between the elements
Using HTML comments (<!-- -->) to occupy the gap
Floating the elements left
Example of removing the white space between elements:
<div class="widget">
<div class="button">
<div class="content">
<div class="icon">A</div>
<div class="label">ABC</div>
</div>
</div><div class="button">
<div class="content">
<div class="icon">B</div>
<div class="label">ABCDEF</div>
</div>
</div><div class="button">
<div class="content">
<div class="icon">C</div>
<div class="label">ABCDEFGHI</div>
</div>
</div>
</div>
jsFiddle example
Example of using HTML comments:
<div class="widget">
<div class="button">
<div class="content">
<div class="icon">A</div>
<div class="label">ABC</div>
</div>
</div><!--
--><div class="button">
<div class="content">
<div class="icon">B</div>
<div class="label">ABCDEF</div>
</div>
</div><!--
--><div class="button">
<div class="content">
<div class="icon">C</div>
<div class="label">ABCDEFGHI</div>
</div>
</div>
</div>
jsFiddle example
Example of using float:
.button {
display:inline-block;
border:1px solid red;
margin:0px;
padding:0px;
float:left;
}
jsFiddle example
So in short this really doesn't have to do with display:table-cell but everything to do with display:inline and inline-block.
in this fiddle i removed the space simply using
float:left;
http://jsfiddle.net/dd7h7/5/
inline-block is adding that unnecessary space.
You can do a little trick with font size:
.widget {
display:block;
margin:0px;
padding:0px;
font-size: 0;
}
.button {
display:inline-block;
border:1px solid red;
margin:0px;
padding:0px;
font-size: initial;
}
I think you should add
float:left
to
.button
so CSS should be like this
.button {
display:inline-block;
border:1px solid red;
margin:0px;
padding:0px;
float: left;
}
Hope, that will help. :)
How to position 3 divs - 3 chunks of text link on the same line in left, center and right?
I need it to position under Joomla article 3 navigation links: PREV, INDEX, NEXT - on the same line...PREV - on left, INDEX - center and NEXT-right;
I know I cannot use float, because there is no float center; if I am trying to use divs - they are not on the same line again...
for example I was trying with
<div style="width:700px;">
<div style="width:50px; margin-left:20px;">Prev</div>
<div style="width:50px; margin-left:350px;">Index</div>
</div>
Here you go.
WORKING DEMO
The HTML:
<div class="wrapper">
<div class="equal left">PREV</div>
<div class="equal center">INDEX</div>
<div class="equal right">NEXT</div>
</div>
The CSS:
.wrapper{width:100%; display:table;}
.equal{display:table-cell;}
.left{text-align:left;}
.center{text-align:center;}
.right{text-align:right;}
Hope this helps.
If you want to put a div in the center of the page horizontally, you can use the css
margin-left: auto; margin-right:auto;
try this one
<div class="main">
<div class="div1">
<div class="div2"></div>
<div class=="div3"></div>
</div>
<div class="div4"></div>
</div>
and in css
.div1 {
float:left;
}
.div4 {
float:right;
}
.div2 {
float:left;
}
.div3 {
float:right;
}
You could always do it via a list like so:
HTML:
<ul class="pagination">
<li>Prev</li>
<li>Next</li>
</ul>
CSS:
ul.pagination {
width: 700px;
}
ul.pagination li {
float: left;
list-style: none;
}
<div style="width:700px;">
<div style="width:50px; margin-left:20px;display: inline-block;">Prev</div>
<div style="width:50px; margin-left:350px;display: inline-block;">Index</div>
</div>
DEMO
.master{width:100%; text-align:center; }
.master div{display:inline}
.left{float:left}
.right{float:right}
I have some divs floating inside another one and I want to align them to the bottom.
This is the HTML:
<div class="magazinebookcase">
<div class="books">
<a title="Mag1" style="height:286px;width:16px;" href="">
</a>
</div>
<div class="books">
<a title="Mag2" style="height:258px;width:48px;" href="">
</a>
</div>
<div class="books">
<a title="Mag3" style="height:252px;width:38px;" href="">
</a>
</div>
<div class="books">
<a title="Mag4" style="height:258px;width:50px;" href="">
</a>
</div>
<div class="books">
<a title="Mag5" style="height:284px;width:14px;" href="">
</a>
</div>
<div class="clearfix"></div>
</div>
And the CSS:
.magazinebookcase {
width: 100%;
padding: 3px;
vertical-align:bottom;
}
.magazinebookcase .clearfix {
clear:both;
}
.magazinebookcase .books {
text-align:center;
float:left;
position: relative;
vertical-align:bottom;
}
.magazinebookcase a {
border: 1px solid #000;
display: block;
word-break: break-all;
}
.magazinebookcase a:hover {
background-color: #ccc;
}
I've tried many ways, changing the positions from absolutes to relatives and other things but I can't do it properly. Any help?
You should not use tables for your layout. But the vertical alignment features are very powerful. You could do something like that:
display: table-cell;
vertical-align: bottom;
I made a jsFiddle that demonstrates how it works.
CSS should be like this:
.left {
display:block;
position:relative;
height:200px;
float:left;
}
.bottom {
position:absolute;
bottom:0;
}
.clear {
clear:both;
}
HTML
<div class="left">
<div class="bottom"></div>
</div>
<div class="left">
</div>
<div class="clear"></div>
Use tables instead. It's my recommendation. On each td use valign:bottom.