I am left with 2 labels and can't find solution.
I have done this much HTML and CSS
<div id="incoming_call" class="bottom_toolbar_incoming_call" style="bottom:90px; position: fixed; right: 3px; z-index: 9999; height:45px; width:250px; background-color:lightgray;">
<img src="http://findicons.com/files/icons/766/base_software/128/circle_red.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:200px; position: relative;" id="Reject" />
<img src="http://findicons.com/files/icons/766/base_software/128/circle_green.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:100px; position: relative;" id="answer" />
</div>
I would put the images inside a position:absolute div like this
#incoming_call{
border: 2px solid black;
}
#call{
color:green;
}
#images{
position:absolute;
top:0px;
}
<div id="incoming_call" class="bottom_toolbar_incoming_call" style="bottom:90px; position: fixed; right: 3px; z-index: 9999; height:45px; width:250px; background-color:lightgray;">
<div id="call">call from 7040</div>
<div id="time">0:01</div>
<div id="images">
<img src="http://findicons.com/files/icons/766/base_software/128/circle_red.png" alt="Reject" style=" width:40px; height:40px; display: inline-block; padding:2px; left:200px; position: relative;" id="Reject" />
<img src="http://findicons.com/files/icons/766/base_software/128/circle_green.png" alt="Answer" style=" width:40px; height:40px; display: inline-block; padding:2px; left:100px; position: relative;" id="answer" />
</div>
</div>
Try this way:
Takes care of vertical alignment (as it appears in your design)
Content height adjusts according to adjacent column
No browser issues as well
Red and Green color using CSS - Hence no images required
.parent-container {
width: 320px;
}
.box {
border: 2px solid #000;
display: table;
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.box__cell {
display: table-cell;
width: 50%;
vertical-align: middle;
padding: 0 15px;
}
ul {
padding: 0;
list-style-type: none;
}
.circle {
width: 20px;
height: 20px;
border-radius: 50%;
border: 2px solid #000;
}
.b-red {
background: red;
}
.b-green {
background: green;
}
.t-green {
color: green;
}
.text-right {
text-align: right;
}
.list-item li {
display: block;
}
.list-inline li {
display: inline-block;
}
<div class="parent-container">
<div class="box">
<div class="box__cell box__cell--left">
<div id="incoming_call">
<ul class="list-item">
<li class="t-green">Incoming Call</li>
<li><b>00: 05</b></li>
</ul>
</div>
</div>
<div class="box__cell box__cell--left">
<ul class="list-inline text-right">
<li class="circle b-red">
</li>
<li class="circle b-green">
</li>
</ul>
</div>
</div>
</div>
Related
Here is a JSFiddle of what I have so far:
JSFiddle Link
html
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 7 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 1 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="histogramBar"> </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
</ul>
</div>
css
.answerDiv, .resultDiv, .histogramBar {
display: inline-block;
}
.answerDiv, .histogramBar {
float: left;
}
.answerDiv {
margin-right: 10px;
width: 100px;
}
.histogramBar {
height: 6px;
width: 100px;
background-color: #66dd66;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
}
.histogramBar:hover {
width: 150px;
}
/*text*/
h2 {
font-size: 40px;
color: black;
}
/*alignment*/
.results {
width: 400px;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
I'm having some trouble, however, getting all the alignment stuff right. My goal is to have the text inside the .answerDiv's all float left. If the text was longer, at a certain point it would wrap to a second line. Then, the histogramBar would also float left and sit just to the right of the text. Then, the results number would float right to the opposite side of the containing div. Additionally, I can't figure out how to make the number on the right stay still when the histogramBar's width changes.
Unfortunately, I cannot figure out how to get this to work properly. I'm relatively new to styling so I'm well aware that my code might be really ugly.
How do I accomplish this?
Recap - text floats left, histogram bar floats left (just right of text) numbers float right. when you hover over the bar and it's size changes, the number on the right should not be affected.
For the text to be right-aligned, in you configuration positioning it absolutely based on <li> is the easiest way:
.resultDiv {
text-align: right;
position: absolute;
right: 0;
}
For that to work, you have to add position: relative; to your .resultsListItems.
I changed your example a bit with regard to styling to showcase the elements better.
.answerDiv,
.resultDiv,
.histogramBar {
display: inline-block;
font-size: 14px;
vertical-align: top;
}
.answerDiv {
margin-right: 10px;
width: 100px;
}
.histogramBar {
height: 6px;
width: 100px;
background-color: red;
margin-top: 9px;
border-radius: 5px;
transition: all 1s;
}
.histogramBar:hover {
width: 150px;
}
/*text*/
h2 {
font-size: 40px;
color: black;
}
/*alignment*/
.results {
width: 400px;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
font-size: 0;
}
.resultsListItem {
list-style-type: none;
position: relative;
}
.resultsListItem:nth-of-type(even) {
background-color: #f8f8ff;
}
.results ul {
margin: 0;
padding: 0;
}
.resultDiv {
text-align: right;
position: absolute;
right: 0;
}
<div class="results">
<h2>Some data</h2>
<ul style="">
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">7</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text that will wrap to a new line</div>
<div class="histogramBar"></div>
<div class="resultDiv">821</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">4</div>
</li>
<li class="resultsListItem">
<div class="answerDiv">text</div>
<div class="histogramBar"></div>
<div class="resultDiv">14</div>
</li>
</ul>
</div>
May this help you.
wrap the class="histogramBar div inside another div. and set the width.
HTML
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv">text</div>
<div class="x">
<div class="histogramBar"></div>
</div>
<div class="resultDiv"> 4</div>
</li>
<br>
<li class="resultsListItem" style="list-style-type: none;">
<div class="answerDiv">text</div>
<div class="x">
<div class="histogramBar"></div>
</div>
<div class="resultDiv"> 4</div>
</li>
<br>
</ul>
Sass
$mainColor: #66dd66;
.answerDiv, .resultDiv, .x
{
display: inline-block;
}
.answerDiv, .histogramBar
{
float: left;
}
li div{border:1px solid red}
.answerDiv
{
margin-right: 10px;
width: 100px;
}
.x{width:160px} /*Now .histogramBar is inside .x*/
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
Remove borders and and put the hover on .x
This will fix your numeric text on right and also when you hover on .x it will not affect numeric values.
Do come back if you get any issues.
If it were me, I would do something like this:
$mainColor: #66dd66;
.answerDiv, .resultDiv, .histogramBar
{
display: inline-block;
border:1px solid red;
}
.results
{
border:1px solid red;
}
.answerDiv, .histogramBar
{
float: left;
}
.answerDiv
{
margin-right: 10px;
width: 100px;
}
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
.resultDiv
{
}
.resultsListItem
{
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.answersListItem
{
position:relative;
top:30px;
left:20px;
width:100px;
border:1px solid red;
float:left;
}
.histogramListItem
{
position:relative;
top:10px;
left:50px;
width:100px;
height:72px;
border:1px solid red;
float:left;
}
.resultListItem
{
position:relative;
top:-10px;
float:right;
border:1px solid red;
width:10px;
margin-right:50px;
}
<html>
<body>
<div class="results">
<h2>Some data</h2>
<ul style="margin:0;padding:0;">
<li class="answersListItem" style="list-style-type: none;">
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
<div class="answerDiv"> text </div>
</li>
<br>
<li class="histogramListItem" style="list-style-type: none;">
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
<div class="histogramBar"> </div>
</li>
<br>
<li class="resultListItem" style="list-style-type: none;">
<div class="resultDiv"> 7 </div>
<div class="resultDiv"> 1 </div>
<div class="resultDiv"> 4 </div>
<div class="resultDiv"> 4 </div>
</li>
<br>
</ul>
</div>
</body>
</html>
check the Updated fiddle. https://jsfiddle.net/e1xrwyLv/4/
If I clearly understood your problem then following css should resolve your problem.
CSS
$mainColor: #66dd66;
.resultsListItem{
margin-bottom:5px;
&:after{
clear:both;
content:'';
display:block;
}
}
.answerDiv, .resultDiv, .histogramBar
{
display: inline-block;
}
.answerDiv, .histogramBar
{
float: left;
}
.answerDiv
{
margin-right: 10px;
width: auto;
max-width:200px
}
.histogramBar
{
height: 6px;
width: 100px;
background-color: $mainColor;
margin-top: 9px;
border-radius: 5px;
transition: width 1s;
&:hover
{
width: 150px;
}
}
.resultDiv
{
float:right;
}
.resultsListItem
{
}
/*text*/
h2
{
font-size: 40px;
color: black;
}
/*alignment*/
.results
{
width: 400px;
height: 400px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
I am trying to get text to display under my overlapping images. I have two images side by side which are to be voted on so the "VS" image overlaps the other two images in the middle which works perfectly. When I try to get text to display under each image to be voted on, however, it seems to display towards the top behind the images, not underneath as it would normally.
Here's a codepen of what it does at the moment:
http://codepen.io/anon/pen/qdemaz
html:
<div align="center">
<div id="vs">
<img id="png1" src="/puppies/8.jpg" /><p
class="left">username<br>Description<br>Puppies name</p>
<img id="png2" src="/images/vs.png" />
<img id="png3" src="/puppies/8.jpg" /><p
class="right">username<br>Description<br>puppies name</p>
</div>
</div>
css:
#png1 {
position:absolute;
top:30px;
left:0;
z-index:0;
}
#png2 {
position:absolute;
top:100px;
left:260px;
z-index:1;
}
#png3 {
position:absolute;
top:30px;
left:315px;
z-index:0;
}
#vs{
position: relative;
width: 620px;
height: 310px;
}
p.left{
position:absolute;
top:315px;
left:0px;
z-index:4;
text-align:left;
}
p.right{
position:absolute;
top:315px;
left:315px;
z-index:4;
text-align:left;
}
I think I see what you're looking to do. You're setup isn't the best. I reworked the HTML/CSS, is this what you want:
http://codepen.io/anon/pen/pJMeGr
a{
display: inline-block;
vertical-align: top;
position: relatve;
z-index: 9;
}
img{
display: inline-block;
border: 1px solid #333;
}
.left{
margin-right: -15px;
}
.right{
margin-left: -10px;
}
#vs{
text-align: center;
}
.vs{
display: inline-block;
vertical-align: top;
position: relative;
z-index: 10;
border: 1px solid #000;
margin-top: 8px;
}
<div>
<div id="vs">
<a class="left" href="#"><img src="http://placehold.it/120x120" />
<br>puppies name
<br>username
<br>Description
</a>
<img class="vs" src="http://placehold.it/100x100" />
<a class="right" href="#"><img src="http://placehold.it/120x120" />
<br>puppies name
<br>username
<br>Description
</a>
</div>
</div>
When I mouse hover the image my REGISTER HERE link is getting hidden.
I don't want hover effect on it but i want that link on the same position below the image.
.image {
position:relative;
display:inline-block;
margin:10px;
}
.overlay {
display:none;
}
.image:hover .overlay {
width:100%;
height:100%;
background:rgba(0,0,0,.5);
border:10px solid red;
position:absolute;
top:0;
left:0;
display:inline-block;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
text-align:center;
color:white;
padding:12px;
font-size:20px;
}
img {
vertical-align:top;
}
<a href="#" class="course">
<div class="image">
<figure>
<img src="http://placekitten.com/250/200" width="100%" height:"100%">
<div class="overlay">Click on the Register Here to know about the:-
<ul>
<li>Oracle</li>
<li>Automated Testing</li>
</ul>
</div>
<figcaption>Register Here</figcaption>
</figure>
</div>
</a>
Added below style -
.course{
position: relative;
display: block;
}
.image {
position: relative;
display: inline-block;
margin: 10px;
}
.overlay {
display: none;
}
.image a:hover .overlay {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .5);
border: 10px solid red;
position: absolute;
top: 0;
left: 0;
display: inline-block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
color: white;
padding: 12px;
font-size: 20px;
pointer-events:none;
}
img {
vertical-align: top;
}
.course{
position: relative;
display: block;
}
<a href="#" class="course">
<div class="image">
<figure>
<img src="http://placekitten.com/250/200" width="100%" height: "100%">
<div class="overlay">Click on the Register Here to know about the:-
<ul>
<li>Oracle</li>
<li>Automated Testing</li>
</ul>
</div>
<figcaption>Register Here
</figcaption>
</figure>
</div>
</a>
How to place an image between a fixed header/footer and prevent overlap?
How to centre an image on the page when the window is bigger than its max-width/height?
The current working example: http://john-marshall.net
CSS
#content {
position:relative;
}
#headerwrap {
position:fixed;
width: 100%;
height:60;
background-color:#fff;
z-index:99;
}
#header {
border-top: 1px solid #000;
margin:20 20 0 20;
}
#title {
font-size:15px;
font-family: "Fugue-Regular";
font-weight:100;
padding-top:5px;
}
#footerwrap {
position:fixed;
width: 100%;
height:60;
bottom:0;
background-color:#fff;
z-index:99;
}
#footer {
border-bottom: 1px solid #000;
height:40;
margin:0 20 20 20;
}
/*gallery*/
#gallerywrap{
position:fixed;
margin:60 20 60 20;
text-align: center;
}
#gallery{
width:100%;
height:auto;
}
.img {
max-width: 100%;
max-height: 100%;
}
HTML
<body>
<div id="content">
<div id="headerwrap">
<div id="header">
<div id="title">John Marshall</div>
<div id="menuli">
<ul>
<li>Project 1</li>
</ul>
</div>
</div>
</div>
<div id="gallerywrap">
<div id="gallery">
<img src="http://john-marshall.net/images/selected/cafe.jpg" class="img" alt="Cafe" />
</div>
</div>
<div id="footerwrap">
<div id="footer">
</div>
</div>
CSS :
#gallery{
width:100%;
height:auto;
margin:0px auto;
}
try this and check your margin in #gallerywrap.
Make the following changes to your css :
#gallerywrap {
position: fixed;
margin: 60px 0px 60px 0px;
text-align: center;
width: 100%;
}
Is this the effect you are looking for ?
I'm currently working on some web coursework and as you'll notice I lack experience in web development. Basically I'm trying to create tables that hold products for a shop, however I want to use div tree's for the most part and if necessary forms for the text.
Essentially I want each independent table to hold an image, a description and eventually other data implemented with JS (I don't need help with this.. yet ^^). Hopefully you'll see what I'm trying to do from the code;
<div id="items">
<div id="item1" class="items">
<img src="img/products/robot1.jpg"/>
</div>
<div id="item2" class="items">
<img src="img/products/robot2.jpg"/>
</div>
<div id="item3" class="items">
<img src="img/products/robot3.jpg"/>
</div>
</div>
#content {
width: 600px;
padding-top: 10px;
padding-bottom: 30px;
margin-left: auto;
margin-right: auto;
}
.items{
display:inline;
}
#items {
padding-top:10px;
}
#items img{
border: 1px solid rgba(207, 207, 207, .7);
border-radius:20px;
}
The div's are parented by the 'content' container which is 600px wide, each table would have to be roughly 193px wide to fit three "products" on a row taking margins into consideration.
I drew a quick picture to represent exactly what I'm aiming for (the 'button' represents the 'add to basket' feature).
Unfortunately I can't use any frameworks such as jquery for the task so I'm stuck doing things the hard way. Apologies in advance for my lack of experience but hopefully you can put me in the right direction.
Edit: Using div's is just a preference, if it would be easier to use standalone forms I wouldn't mind.
Maybe this will point you in the right direction.
HTML:
<div id="content" class="clearfix">
<div id="items">
<div id="item1" class="items">
<img src="img/products/robot1.jpg"/>
Add
</div>
<div id="item2" class="items">
<img src="img/products/robot2.jpg"/>
Add
</div>
<div id="item3" class="items">
<img src="img/products/robot3.jpg"/>
Add
</div>
</div>
</div>
CSS:
.clearfix { *zoom: 1; }
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
#content {
width: 600px;
padding-top: 10px;
padding-bottom: 30px;
margin-left: auto;
margin-right: auto;
background:red;
}
.items{
float:left;
width:193px;
min-height:100px;
border:1px solid black;
position:relative;
}
.items a.add-basket {
position:absolute;
bottom:0;
right:0;
background:black;
color:#fff;
}
#item1 { margin-right:7px; }
#item2 { margin-right:7px; }
#items {
padding-top:10px;
}
#items img {
border: 1px solid rgba(207, 207, 207, .7);
border-radius:20px;
}
http://jsfiddle.net/DNS8P/1/
Here's a FIDDLE by the image you provide.
<div id="content">
<h1>Products</h1>
<div id="items">
<div id="item1" class="items">
<img src="img/products/robot1.jpg"/>
<span class="desc">Description</span>
<span class="price">$100</span>
<span class="other">Other</span>
<button>BUY</button>
</div>
<div id="item2" class="items">
<img src="img/products/robot2.jpg"/>
<span class="desc">Description</span>
<span class="price">$100</span>
<span class="other">Other</span>
<button>BUY</button>
</div>
<div id="item3" class="items">
<img src="img/products/robot3.jpg"/>
<span class="desc">Description</span>
<span class="price">$100</span>
<span class="other">Other</span>
<button>BUY</button>
</div>
</div>
</div>
#content {
width: 600px;
padding: 10px 10px 30px 10px;
margin: 30px auto;
text-align: center;
border: 1px solid #999;
}
#items {
padding-top:10px;
}
.items{
display: inline-block;
text-align: center;
width: 180px;
margin: 0 7px 0 7px;
padding-top: 10px;
border: 1px solid #999;
border-radius: 20px;
}
.items img {
width: 160px;
height: 140px;
border: 1px solid rgba(207, 207, 207, .7);
}
.items button {
background: #666;
width: 80px;
height: 26px;
float: right;
border-top: 1px solid #999;
border-left: 1px solid #999;
border-right: none;
border-bottom: none;
outline: none;
cursor: pointer;
border-bottom-right-radius: 20px;
transition: background 0.2s ease-in;
}
.items button:hover {
background: #888;
}
.desc,
.price,
.other {
display: block;
margin-bottom: 10px;
}