How to position the check box inside li element to center? - html

I have a list of items with a div content and a span with check box. I want to position my check box span to center of li element.
<li class="e-list e-state-default e-list-check">
<div class="cont-bg">
content here varies
</div>
<span >
<input class="e-lv-check e-checkbox e-js e-input" type="checkbox"/>
</span>
</li>
Content is loaded dynamically so its height and width varies. I couldn't set padding for positioning. Tried on positioning using vertical-align as well. Nothing worked.
.e-list.e-state-default {
background-color: #fff;
border-color: #c8c8c8;
}
.e-list {
border-bottom: 1px solid #c8c8c8;
font-size: 12px;
}
.cont-bg {
font-size: 17px;
height: 100px;
padding-left: 5px;
padding-top: 10px;
width: 80%;
display: inline-block;
}
.e-list .e-lv-checkdiv {
float: right;
}
.e-list {
border-bottom: 1px solid #c8c8c8;
font-size: 12px;
}
.e-list {
line-height: normal;
padding: 0 15px;
cursor: pointer;
vertical-align: middle;
}
<ul>
<li class="e-list e-state-default e-list-check">
<div class="cont-bg">
<div class="brooke">
</div>
<div class="listrightdiv">
<span class="templatetext">Brooke</span> <span class="designationstyle">HR Assistant</span>
<div class="aboutstyle">
Brooke provides administrative support to the HR office. Brooke provides administrative support to the HR office. Brooke provides administrative support to the HR office.
</div>
</div>
</div>
<span><input class="e-lv-check e-checkbox e-js e-input" type="checkbox" tabindex="" name="null" value="true" /> </span>
</li>
<li class="e-list e-state-default e-list-check">
<div class="cont-bg">
<div class="brooke">
</div>
<div class="listrightdiv">
<span class="templatetext">Brooke</span> <span class="designationstyle">HR Assistant</span>
<div class="aboutstyle">
Brooke provides administrative support to the HR office. Brooke provides administrative support to the HR office. Brooke provides administrative support to the HR office.
</div>
</div>
</div>
<span><input class="e-lv-check e-checkbox e-js e-input" type="checkbox" tabindex="" name="null" value="true" /> </span>
</li>
</ul>
Can any one help me?

Why are you mixing <div> and <span>? Having both in span will give you right results right? You can use something like this:
.e-list,
.e-list span {vertical-align: middle; text-align: center;}
<li class="e-list e-state-default e-list-check">
<span class="cont-bg">
content here varies
</span>
<span>
<input class="e-lv-check e-checkbox e-js e-input" type="checkbox"/> This is centered.
</span>
</li>
If for some reason, you cannot change your <div> to <span>, use:
.e-list {vertical-align: middle; text-align: center;}
.e-list div,
.e-list span {vertical-align: middle; text-align: center; display: inline-block;}
<li class="e-list e-state-default e-list-check">
<div class="cont-bg">
content here varies
</div>
<span>
<input class="e-lv-check e-checkbox e-js e-input" type="checkbox"/> This is centered.
</span>
</li>

Related

How to show more information, when user hovers?

I have an info icon which when the user hovers over, is able to see more information. The icons are pngs and I DO NOT want to change the position of the image, so is there any idea about using tooltips with images in my case? I also would like the tooltip to look like this:
Example Tooltip
This is my HTML:
<div class="modeHolder">
<div class="toggle">
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
<div class="mode">
<p>Ipad Mode</p>
</div>
<div class="infoIcon">
<img src="images/info.png" alt="info icon">
</div>
<div class="settings">
<img src="images/settings.png" alt="settings icon">
</div>
</div>
<div class="modeHolder">
<div class="toggle">
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
<div class="mode">
<p>Mac Mode</p>
</div>
<div class="infoIcon">
</div>
<div class="settings"></div>
</div>
</div>
Thank you in advance
Codepen: https://codepen.io/D4SH13/pen/jOmOWqb
1st: Using Title tag in <img> element.
<div class="infoIcon">
<a href="#">
<img title="Extra Info" src="https://cdn.onlinewebfonts.com/svg/img_151567.png" alt="info icon" />
</a>
</div>
Final Code
Code Pen: https://codepen.io/gautam25raj/pen/poPoeNy
2nd: Using <span> element.
Take a <span> element and put it inside your tootltip container.
<div class="infoIcon">
<!-- New span element -->
<span class="extraInfo">Extra Info</span>
</div>
Make the <span> postion: absolute relative to your tooltip container position: relative and add some styles to <span> element.
.infoIcon {
position: relative;
}
.extraInfo {
position: absolute;
color: #fff;
background-color: #000;
border-radius: 5px;
padding: 2px 5px;
width: 70px;
text-align: center;
}
Now, change the visibility of the span element. So that it can stay hidden until the tooltip is hovered.
visibility: hidden;
i.e.
.extraInfo{
position: absolute;
color: #fff;
background-color: #000;
border-radius: 5px;
padding: 2px 5px;
width: 70px;
text-align: center;
visibility: hidden;
}
Now, when your tooltip is hover make the span element visible.
.infoIcon:hover .extraInfo {
visibility: visible;
}
Final Code
Code Pen: https://codepen.io/gautam25raj/pen/xxdxgrO
Hope this solves your problem

Make a Div vertically fill its parent [duplicate]

This question already has answers here:
Percentage Height HTML 5/CSS
(7 answers)
Closed 4 years ago.
I'm trying to get 2 divs to appear side by side in their parent and to both vertically fill the parent. I've tried setting height and min-height to 100% but I don't understand why its not working.
Here is my html:
<div class="calc-wrap clear">
<h2>Title</h2>
<div class="calc-content clear">
<div class="calc-form">
<form id="cost_calculator">
<fieldset>
<legend>
<h3>Find out how much your stuff costs you</h3>
</legend>
<ol>
<li class="one">
<label for="cost_of_pack">quantity</label>
<span class="pound-label">£</span>
<input type="number" id="cost_of_pack" name="cost_of_pack" value="0.0" min="0" step="0.10">
</li>
<li class="two">
<label for="quantity_smoked">How many per day?</label>
<input type="number" id="quantity_smoked" name="quantity_smoked" value="0">
</li>
</ol>
</fieldset>
</form>
</div>
<div class="calc-save">
<div class="calc-results-content clear">
<h3>Results</h3>
<div class="calc-results">
<div>
<p id="weekly_cost">£<span>0.00</span> per week</p>
<p id="monthly_cost">£<span>0.00</span> per month</p>
<p id="annual_cost" class="noborder">£<span>0.00</span> per year</p>
</div>
</div>
<div class="calc-quitnow">
<p>Well done</p>
</div>
</div>
</div>
</div>
</div>
And CSS:
.calc-content {
display: inline-block;
border: 3px solid blue;
width: 100%;
border-color: #87B7CD;
}
.calc-form,
.calc-save {
height:100%;
border: 1px solid red;
float: left;
}
.calc-form {
width: 60%;
}
.calc-save {
width: 39%;
background-color: #87B7CD;
}
.calc-results {
float: left;
width: 60%;
}
And a JS Fiddle
Any help would be much appreciated.
You can use "the Flex powers"! ;)
.calc-content {
display: flex;
/*display: inline-block;*/
border: 3px solid blue;
width: 100%;
border-color: #87B7CD;
}
.calc-form,
.calc-save {
border: 1px solid red;
/*float: left;*/
}
.calc-form {
width: 60%;
}
.calc-save {
width: 39%;
background-color: #87B7CD;
}
.calc-results {
float: left;
width: 60%;
}
<div class="calc-wrap clear">
<h2>Title</h2>
<div class="calc-content clear">
<div class="calc-form">
<form id="cost_calculator">
<fieldset>
<legend>
<h3>Find out how much your stuff costs you</h3>
</legend>
<ol>
<li class="one">
<label for="cost_of_pack">quantity</label>
<span class="pound-label">£</span>
<input type="number" id="cost_of_pack" name="cost_of_pack" value="0.0" min="0" step="0.10">
</li>
<li class="two">
<label for="quantity_smoked">How many per day?</label>
<input type="number" id="quantity_smoked" name="quantity_smoked" value="0">
</li>
</ol>
</fieldset>
</form>
</div>
<div class="calc-save">
<div class="calc-results-content clear">
<h3>Results</h3>
<div class="calc-results">
<div>
<p id="weekly_cost">£<span>0.00</span> per week</p>
<p id="monthly_cost">£<span>0.00</span> per month</p>
<p id="annual_cost" class="noborder">£<span>0.00</span> per year</p>
</div>
</div>
<div class="calc-quitnow">
<p>Well done</p>
</div>
</div>
</div>
</div>
</div>
This is because the parent <div> has no defined height, so obviously, the children elements can't fill 100% of the parents' height.
Add a height to your parent's class calc-content, e.g. height: 200px;.
calc-content {
display: inline-block;
border: 3px solid blue;
width: 100%;
height: 200px;
border-color: #87B7CD;
}
One way is to use display: flex or display: inline-flex in your .calc-content rule.
Use display: flex on calc-content and keep the form element inside the fieldset element like shown below. Also need for float left now.
.calc-content {
display: flex;
border: 3px solid blue;
width: 100%;
border-color: #87B7CD;
}
.calc-form,
.calc-save {
height: 100%;
border: 1px solid red;
}
.calc-form {
width: 60%;
}
fieldset {
width: 60%;
}
.calc-save {
width: 40%;
background-color: #87B7CD;
}
.calc-results {
float: left;
width: 60%;
}
<div class="calc-wrap clear">
<h2>Title</h2>
<div class="calc-content ">
<fieldset>
<legend>
<h3>Find out how much your stuff costs you</h3>
</legend>
<form id="cost_calculator">
<ol>
<li class="one">
<label for="cost_of_pack">quantity</label>
<span class="pound-label">£</span>
<input type="number" id="cost_of_pack" name="cost_of_pack" value="0.0" min="0" step="0.10">
</li>
<li class="two">
<label for="quantity_smoked">How many per day?</label>
<input type="number" id="quantity_smoked" name="quantity_smoked" value="0">
</li>
</ol>
</form>
</fieldset>
<div class="calc-save">
<div class="calc-results-content clear">
<h3>Results</h3>
<div class="calc-results">
<div>
<p id="weekly_cost">£<span>0.00</span> per week</p>
<p id="monthly_cost">£<span>0.00</span> per month</p>
<p id="annual_cost" class="noborder">£<span>0.00</span> per year</p>
</div>
</div>
<div class="calc-quitnow">
<p>Well done</p>
</div>
</div>
</div>
</div>
</div>
Are you trying to do like this:
Removed height from .calc-form, .calc-save & modified .calc-content with
display: flex;
.calc-content {
display: flex;
border: 3px solid blue;
width: 100%;
border-color: #87B7CD;
}
.calc-form,
.calc-save {
border: 1px solid red;
float: left;
}
.calc-form {
width: 60%;
}
.calc-save {
width: 39%;
background-color: #87B7CD;
}
.calc-results {
float: left;
width: 60%;
}
<div class="calc-wrap clear">
<h2>Title</h2>
<div class="calc-content clear">
<div class="calc-form">
<form id="cost_calculator">
<fieldset>
<legend>
<h3>Find out how much your stuff costs you</h3>
</legend>
<ol>
<li class="one">
<label for="cost_of_pack">quantity</label>
<span class="pound-label">£</span>
<input type="number" id="cost_of_pack" name="cost_of_pack" value="0.0" min="0" step="0.10">
</li>
<li class="two">
<label for="quantity_smoked">How many per day?</label>
<input type="number" id="quantity_smoked" name="quantity_smoked" value="0">
</li>
</ol>
</fieldset>
</form>
</div>
<div class="calc-save">
<div class="calc-results-content clear">
<h3>Results</h3>
<div class="calc-results">
<div>
<p id="weekly_cost">£<span>0.00</span> per week</p>
<p id="monthly_cost">£<span>0.00</span> per month</p>
<p id="annual_cost" class="noborder">£<span>0.00</span> per year</p>
</div>
</div>
<div class="calc-quitnow">
<p>Well done</p>
</div>
</div>
</div>
</div>
</div>
.parentDiv {
height: 250px;
background: black;
display:flex;
}
.childDiv {
width:50%;
background: grey;
padding:10px;
border:1px solid black
}
<div class="parentDiv">
<div class="childDiv">
text1
</div>
<div class="childDiv">
text2
</div>
</div>

Can't seem to get two elements to be side-by-side

Here is what my webpage looks like:
As I highlighted in the picture, I'm trying to move the balance element to the right side.
I am trying to use the display:inline-block tag to do this.
Here is my CSS and HTML... what am I doing wrong?
CSS:
/* Game box */
.gamebox{
height: auto;
margin: 20px;
padding: 20px;
width: 50%;
font-family: "smooth";
background-color: white;
color: black;
box-shadow: 4px 4px lightgray;
display:inline-block;
}
/* Balance box */
.balance{
height: auto;
margin: 20px;
padding: 20px;
width: 50%;
font-family: "smooth";
background-color: white;
color: black;
box-shadow: 4px 4px lightgray;
display:inline-block;
}
HTML:
<body>
<div class="noselection">
<ul class="topnav">
<li><a class="active" href="#home"><i class="fa fa-rocket" aria-hidden="true"></i> Play</a></li>
<li><i class="fa fa-btc" aria-hidden="true"></i> Deposit</li>
<li><i class="fa fa-btc" aria-hidden="true"></i> Withdraw</li>
<li><i class="fa fa-university" aria-hidden="true"></i>Faucet</li>
<li><i class="fa fa-life-ring" aria-hidden="true"></i>Help & Support</li>
<?php echo $accountButton; ?>
<li class='right' id="top-balance"><a href=''></a></li>
</ul>
<div class="gamebox">
<h1><i class="fa fa-btc" aria-hidden="true"></i>itcoin dice game</h1>
<div class="error" id="error">You don't have anymore bitcoins left. Why not deposit some more?</div>
<form id="index">
Bet
<br>
<span>
<input id="userbet" onkeyup="checkBet()" value="100" type="text" name="bet" autocomplete="off">
<span id="beterror" class="errortext">That bet is not a valid bet.</span>
<span id="x2" class="timestwo" onclick="doubleBet()">x2</span>
<span id="/2" class="dividetwo" onclick="divideBet()">/2</span>
</span>
<br>
<span>
Chance<br>
<input id ="userchance" onkeydown="checkChance()" value="50" type="text" name="chance" autocomplete="off">
<span id="chanceerror" class="errortext">That is not a valid chance.</span>
</span>
<br>
<h3 id="payout">Payout: Loading...</h3>
<script>var username = <?php echo json_encode($_SESSION['username']); ?>;</script>
<script>var hash = <?php echo json_encode($_SESSION['hash']); ?>;</script>
<button type="button" id="dicebutton" onclick="prepareRoll(username, hash);" style="vertical-align:middle"><img src="Images/dice.png"> Roll dice!</button>
</form>
<button type="button" id="autobet" onclick="setAutoBet(true)"><i class="fa fa-rocket" aria-hidden="true"></i> Autobet</button>
<div class="autobet-mode" id="autobet-mode">
<h3 id="auto-bet-start-text">Please set your auto bet settings, then click 'Start rolling'!".</h3>
<button type="button" id="start-autobet" onclick="startAutoBet()">Start rolling!</button>
</div>
</div>
<div class="balance">
<h3 id="balance">Balance: Loading...</h3>
</div>
</div>
<?php echo $script; ?>
</body>
UPDATE:
Reducing the .balance width to 40% fixed the issue, but how can I now force it up?
Try this code
add box-sizing: border-box; property to both the classes.
CSS
.gamebox, .balance{
box-sizing: border-box;
}
hope this helps..
you are looking for below structure,
what happens here is when you apply fixed width to div and them apply padding and margin so your element width gets increased
so better you create another child container and assign padding margin over there
.gamebox, .balance{
width: 50%;
float: left;
height: 100px;
}
.gamebox-inner, .balance-inner{
border: 1px solid red;
padding: 10px;
margin: 10px;
background-color: #ddd;
}
<div class="gamebox">
<div class="gamebox-inner">
a
</div>
</div>
<div class="balance">
<div class="balance-inner">
b
</div>
</div>
You can try flexbox as follows.
<div id="container">
<div class ="first">first</div>
<div class="second">second</div>
</div>
#container {
width: 200px;
height: 300px;enter code here
border: 1px solid black;
backgroud-color:red;
display:flex;
}
.first {
background-color:blue;
width:50px;
height:50px;
flex:1;
}
.second {
background-color:green;
width:50px;
height:50px;
flex:2;
}

Can't make border-radius on DT

Why can't I make a border-radius on my <dt>?
http://thistedbolig.konggulerodhosting.dk/
What can I change? I really need to make the border-radius. I have tried many things, but none of them work. I hope someone here can help me so I can finish the project.
CSS:
.dropdown dt { border-radius: 10px 0px 0px 10px;}
HTML:
<div class="small-6 medium-3 columns">
<dl class="dropdown">
<dt>
<a href="#0">
<span title="city" class="hida " ><img src="assets/images/search/placeholder.svg" alt="" style="width:20px; height:20px; margin-right:10px;">Vælg en by</span>
<p class="multiSel"></p>
</a>
</dt>
<dd>
<div class="mutliSelect">
<ul>
<li>
<input type="checkbox" value="Thisted" />Thisted</li>
<li>
<input type="checkbox" value="Snested" />Snested</li>
<li>
<input type="checkbox" value="Vesløs" />Vesløs</li>
<li>
<input type="checkbox" value="Nors" />Nors</li>
<li>
<input type="checkbox" value="Sennels" />Sennels</li>
<li>
<input type="checkbox" value="Østerild" />Østerild</li>
</ul>
</div>
</dd>
</dl>
</div>
You need to set the border on the a tag in order to apply a border
Thus:
Update:
.dropdown dt {
height: 20px;
line-height: 20px;
display: block;
background: black;
}
.dropdown dt a {
padding: 8px 20px 5px 10px;
overflow: hidden;
border-radius: 10px 0px 0px 10px;
}
should work!
line-height will center the text vertically!
Check this jsfiddle: https://jsfiddle.net/9tgj0n5k/1/

Weird CSS in Internet Explorer (Concerning margins, I believe)

I've got a weird rendering issue in IE concerning an inline unordered list. What I'm trying to do is make a visualizer for the lifespan of a project, but whenever I try to add in any text in my <p> object designed to hold a time period, it shifts the whole <li> element down, but only in Internet Explorer.
Please, take a gander at this issue: https://jsfiddle.net/xny1zv3j/
I'm okay with the name and position (ex: 'John' and 'Project Lead' being pulled down - that's not an issue for me. But in IE, and IE only, it seems as if the entire list element is pulled down. When the <p> element is empty, it's simply ignored, and is fine in all browsers, but when it has content, IE freaks out.
You should be able to simply add vertical-align: top to your .li class.
Is this what you are shooting for? https://jsfiddle.net/xny1zv3j/3/
HTML
<div class="container body-content">
<div class="container" id="main-container">
<ul class="timeline">
<li class="li" >
<div class="timestamp">
<div class="author">John</div>
<div class="date">Project Lead</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Created Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jenny</div>
<div class="date">Programmer</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Built Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jeremy</div>
<div class="date">Marketing</div>
</div>
<div class="status">
<div class="time-period">
<p>2 yrs</p>
</div>
<h4>Advertised Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jack</div>
<div class="date">Sales</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Sold Project</h4>
</div>
</li>
<li class="li" >
<div class="timestamp">
<div class="author">Jebeddiah</div>
<div class="date">IT</div>
</div>
<div class="status">
<div class="time-period">
<p></p>
</div>
<h4>Defended Project</h4>
</div>
</li>
</ul>
</div>
</div>
CSS
.timeline {
text-align: left;
list-style-type: none;
display: inline-block;
margin-bottom:-23px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 5px;
padding-right: 5px;
}
.li {
width: 150px;
display: inline-block;
}
.timestamp {
margin-bottom: 20px;
padding: 0px;
font-weight: 100;
display: block;
white-space: nowrap;
overflow: hidden;
}
.status {
padding-top: 10px;
position: relative;
transition: all 200ms ease-in;
white-space: normal;
}
.status h4 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
padding-bottom: 3px;
}
.time-period {
display: inline;
text-align: center; }
.time-period p {
/* margin: -30px 0px 20px;*/
}
.time-period p:empty {
display:inline-block;
}