I have a PHP script that runs a completion progress bar. I want to display the percentage next to the bar...this should be the easy part. But for some reason, I can't get the percentage to display NEXT to the bar instead of UNDER it.
https://jsfiddle.net/
HTML
<div id="progress_bar_container">
<div id="progress_bar_background">
<div id="progress" style="width: <?php echo $progress_bar_width; ?>px;">
</div>
</div>
<div style="text-align: left; display: inline-block;">
<?php echo $completed_lc_percentage . "%"; ?>
</div>
</div>
CSS
#progress_bar_container {
width: 220px;
height: 20px;
}
#progress_bar_background {
display: block;
background-color: #eaeaea;
width: 200px;
height: 20px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
#progress {
display: block;
background: #a8c25d;
height: 20px;
width: 0px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
You need to make sure that the container is wide enough to hold the two children elements inside, or you can use white-space:nowrap.
Make both children elements to display:inline-block, see the demo follows.
#progress_bar_container {
width: 220px; /*or increase the value*/
height: 20px;
white-space: nowrap; /*added*/
}
#progress_bar_background {
/* display: block; */
display: inline-block; /*added*/
background-color: #eaeaea;
width: 200px;
height: 20px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
#progress {
display: block;
background: #a8c25d;
height: 20px;
width: 0px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
<div id="progress_bar_container">
<div id="progress_bar_background">
<div id="progress"> </div>
</div>
<div style="text-align: left; display: inline-block;">n%</div>
</div>
You need to float the progress_bar_background left, and then widen the width of the progress_bar_container to allow the percentage div to sit next to it. Here's an example of this working:
https://jsfiddle.net/b69ep74e/
You might want to push the progress percentage div down a pixel or two to line it up, and the width of the progress div should be a percentage.
That's because the #progress_bar_background doesn't have display: inline-block and the #progress_bar_container has a fixed width. That fixed width doesn't let space to the text.
Remove the width of #progress_bar_container or increase it. Add display: inline-block to #progress_bar_background and it should work fine.
https://jsfiddle.net/2qn9eecr/
It is because you're #progress_bar_container's allowance space is very little the percentage can't fit in the space NEXT to the bar and you also have to add a float:left; in your #progress_bar_background css.
#progress_bar_container {
width: 300px;
height: 20px;
}
#progress_bar_background {
display: block;
float:left;
background-color: #eaeaea;
width: 200px;
height: 20px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
#progress {
display: block;
background: #a8c25d;
height: 20px;
width: 0px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
-khtml-border-radius: 15px;
border-radius: 15px;
}
<div id="progress_bar_container">
<div id="progress_bar_background">
<div id="progress" style="width: 100px;">
</div>
</div>
<div style="text-align: left; display: inline-block;">
50%
</div>
</div>
Related
The problem is no matter what is inside chat_ttc it will always be 300px.
Snippet:
.chat_ttc {
max-width: 300px;
word-break: break-word;
background: #e5e5e5;
margin-left: 70px;
position: relative;
border-radius: 15px;
border-bottom-left-radius: 0px;
padding: 4px;
padding-left: 6px;
letter-spacing: 0.6;
}
<div class="froma_tc">
<div class="chat_ttc">D</div>
</div>
yaa its because div is block element and it takes 100% of the width
as you have given max-width as 300px width will be always 300px
if you want to take some valid width make div as inline-block
check this snippet
.chat_ttc {
max-width: 300px;
display:inline-block;
word-break: break-word;
background: #e5e5e5;
margin-left: 70px;
position: relative;
border-radius: 15px;
border-bottom-left-radius: 0px;
padding: 4px;
padding-left: 6px;
letter-spacing: 0.6;
}
<div class="froma_tc">
<div class="chat_ttc">D</div>
</div>
Hope this helps
I am trying to make an online portfolio for myself and I have a bottom container for the bottom half of the screen and I would like to place 3 buttons at the top of the container. I have got it to work except when you resize the page. When you shrink the page's width the buttons will overlap. How can I stop them from overlapping? I want them to go close together side by side but not overlap.
h1 {
margin-left: 33%;
margin-right: 33%;
text-align: center;
}
img {
width: 15%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
#top,
#bottom {
position: fixed;
left: 0;
right: 0;
height: 50%;
}
#bottom {
border-top: 2px solid black;
margin-left: auto;
margin-right: auto;
display: block;
float: center;
position: fixed;
border: 2px solid black;
padding: 15px;
padding-bottom: 17px;
}
#navbuttons {
border-top: 2px solid black;
margin-left: auto;
margin-right: auto;
display: block;
float: center;
position: relative;
border: 2px solid black;
padding: 15px;
padding-bottom: 10px;
}
#resumebutton {
display: inline-block;
position: absolute;
top: 0%;
left: 33%;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border: 2px solid black;
border-radius: 20px;
padding: 5px;
background-color: #7dd7f5;
text-align: center;
}
#coverletterbutton {
display: inline-block;
position: absolute;
top: 0%;
left: 46.5%;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border: 2px solid black;
border-radius: 20px;
padding: 5px;
background-color: #7dd7f5;
text-align: center;
}
#portfoliobutton {
display: inline-block;
position: absolute;
top: 0%;
left: 62.5%;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border: 2px solid black;
border-radius: 20px;
padding: 5px;
background-color: #7dd7f5;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>--Name Here-- Resume and Portfolio</title>
</head>
<body>
<div style="height: 100%"></div>
<div id="top"></div>
<h1>--Name Here--</h1>
<img src="http://science-all.com/images/wallpapers/cat-pictures/cat-pictures-20.jpg"/>
<h1>Resume and Portfolio</h1>
<div id="bottom">
<div id="navbuttons">
<div id="resumebutton">Resume</div>
<div id="coverletterbutton">Cover Letter</div>
<div id="portfoliobutton">Portfolio</div>
</div>
</div>
</body>
</html>
I would provide an example if I knew how.
Thank you
you don't need to absolute position the buttons if you have the container fixed. you can use inline-block and just text-align: center on your container. Also there are errors in your css, like there is no float: center;, you can also skip the # and use class as they share css properties. But I agree that Bootstrap is the way to go for responsive, and especially if you are new.
#bottom {
border-top: 2px solid black;
text-align: center;
margin-left: auto;
margin-right: auto;
display: block;
position: fixed;
border: 2px solid black;
padding: 15px;
padding-bottom: 17px;
}
.nav-button {
display: inline-block;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border: 2px solid black;
border-radius: 20px;
padding: 5px;
background-color: #7dd7f5;
text-align: center;
}
<div id="bottom">
<div class="nav-button">Resume</div>
<div class="nav-button">Cover Letter</div>
<div class="nav-button">Portfolio</div>
</div>
The bootstrap grid system is great at this. I recommend using it in combination with some of your custom styles to produce a bottom section split into equally sized columns.
Grids are split into 12 columns, so columns of 4 (e.g. col-md-4) will split into evenly spaced vertically.
For the bottom, that would look something like:
<div id="bottom">
<div id="navbuttons" class="row">
<div id="resumebutton" class="col-md-4">Resume</div>
<div id="coverletterbutton" class="col-md-4">Cover Letter</div>
<div id="portfoliobutton" class="col-md-4">Portfolio</div>
</div>
</div>
You can make these columns wrapper divs if you want to center smaller buttons inside those columns, but the grid structure is a good place to start.
You can just delete attribute position: absolute; from all buttons ( resumebutton, coverletterbutton and portfoliobutton) and add text-align: center to navbuttons selector.
Consider removing the absolutepositioning to replace the elements in question back into the flow of the document. They'll have relation to each other now, so you won't need to rely on positioning rules like left and right.
The elements are already displayed inline-block so just declare a text-align: center rule to the parent and the nested elements will align accordingly.
In the snippet example below, margins have been added around each button for spacing, repetitive rules have been replaced with one instance using a class selector applied to all button elements, note that float: center; is not a valid rule.
Snippet Example
h1 {
margin-left: 33%;
margin-right: 33%;
text-align: center;
}
img {
width: 15%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
#top,
#bottom {
position: fixed;
left: 0;
right: 0;
height: 50%;
}
#bottom {
border-top: 2px solid black;
margin-left: auto;
margin-right: auto;
display: block;
float: center;
position: fixed;
border: 2px solid black;
padding: 15px;
padding-bottom: 17px;
}
#navbuttons {
border-top: 2px solid black;
margin-left: auto;
margin-right: auto;
display: block;
float: center;
/* invalid rule */
position: relative;
border: 2px solid black;
padding: 15px;
padding-bottom: 10px;
text-align: center;
}
#navbuttons .button {
display: inline-block;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border: 2px solid black;
border-radius: 20px;
padding: 5px;
background-color: #7dd7f5;
text-align: center;
margin: 0px 20px;
}
<div style="height: 100%"></div>
<div id="top"></div>
<h1>--Name Here--</h1>
<img src="http://science-all.com/images/wallpapers/cat-pictures/cat-pictures-20.jpg" />
<h1>Resume and Portfolio</h1>
<div id="bottom">
<div id="navbuttons">
<div id="resumebutton" class="button">Resume</div>
<div id="coverletterbutton" class="button">Cover Letter</div>
<div id="portfoliobutton" class="button">Portfolio</div>
</div>
</div>
I want my two "training-border" divs on my page to have their own bottom-borders.
<div class="component-content">
<div class="reporting-div">
<div class = "training-border">
<div class="dots width-75-left row">
<div>
How to Train Your Dragon
</div>
<div class="cell circle-blue"></div>
</div>
<div class="progress-text width-25-right">
2 of 3
</div>
</div>
<div class = "training-border">
<div class="dots width-75-left row">
<div>
How to Play Dumb in Poker
</div>
<div class="cell circle-blue"></div>
</div>
<div class="progress-text width-25-right">
2 of 3
</div>
</div>
</div>
</div>
Both use the following css styles:
.circle-blue {
width: 10px;
height: 10px;
background: deepskyblue;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.circle-gray {
width: 10px;
height: 10px;
background: lightgray;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.cell {
margin-left: 5px;
display: inline-block;
font-size: 6px;
}
.row {
display: table-row;
padding: 3px;
}
.width-75-left {
width: 75%;
float: left;
}
.width-25-right {
width: 25%;
float: right;
text-align: right;
}
.reporting-div {
width: 100%;
}
.training-border{
border-style: solid;
border-bottom: thick dotted #ff0000;
}
.component-content {
display: inline-block;
margin: 20px;
}
What ends up happening, though, is that the border-bottom on the second div floats to the very top of the first div. I want to accomplish the following:
Give each "training-border" div its own border-bottom without the border floating to the top of the first div
Do the above with minimal modification to the other .css classes
Here is the plnkr link. Notice how the bottom border of the second div floats to the top of the first one:
http://plnkr.co/edit/WlsscFkmbuOocEnrz8IX?p=preview
You need to clear the float.
One method is:
.training-border{
border-style: solid;
border-bottom: thick dotted #ff0000;
overflow: hidden; /* this */
}
Demo
I am currently trying to render various circles on a page. I am currently drawing the circles using modified CSS from the following web page:
https://css-tricks.com/examples/ShapesOfCSS/
The CSS for circles in the link above draws the circles, but I am running into a couple of problems:
I need the circles to be spaced apart from one another (maybe 3px?)
I need the circles to be in the same horizontal line
I can't seem to do 1 and 2 at the same time
I am using the following HTML and CSS:
.circle-blue {
width: 10px;
height: 10px;
background: deepskyblue;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.circle-gray {
width: 10px;
height: 10px;
background: gray;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.cell {
display: table-cell;
font-size: 6px;
}
<div class="circle-blue cell"></div>
<div class="circle-gray cell"></div>
<div class="circle-blue cell"></div>
My circle divs in my HTML implement the circle and the cell classes.
The Plunker link below will lead you to my example:
http://plnkr.co/edit/SPHmKyOjF6GbTtjEFPrd?p=preview
NOTE: The circles are small, so you have to look at the very top left corner of the Plunker preview mode to find them.
The issue is that you are setting the div to display: table-cell;. margin does not apply to elements when their display property is set to table-cell. http://www.w3.org/TR/CSS2/box.html#margin-properties states that margin:
Applies to: all elements except elements with table display types other than table-caption, table and inline-table
One way to get the desired result would be to remove display: table-cell; and add float: left; and margin-right: 3px; to the circles instead.
.circle-blue {
width: 10px;
height: 10px;
background: deepskyblue;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.circle-gray {
width: 10px;
height: 10px;
background: gray;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.cell {
/*display:table-cell; Remove this*/
font-size: 6px;
float: left; /*Add this*/
margin-right: 3px; /*Add this*/
}
<div class="circle-blue cell"></div>
<div class="circle-gray cell"></div>
<div class="circle-blue cell"></div>
Use this
.cell{
margin-left: 5px;
display: inline-block;
font-size: 6px;
}
Instead of
.cell{
display: table-cell;
font-size: 6px;
}
when using table don't put content in them like images etc like that put a new div inside the cell specifically for content then use padding on your cell's to give spacing like below.
this way you get to keep cell's fluidity when doing responsive deign and it wont push down like float or inline-block would which I'm assuming you are doing since your using table for display.
.circle-blue {
width: 10px;
height: 10px;
background: deepskyblue;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.circle-gray {
width: 10px;
height: 10px;
background: gray;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.cell {
display: table-cell;
font-size: 6px;
padding: 10px;
}
<div class="cell">
<div class="circle-blue"></div>
</div>
<div class="cell">
<div class="circle-gray"></div>
</div>
<div class="cell">
<div class="circle-blue"></div>
</div>
add this to the class 'cell'.
display: inline-block;
margin: 0 3px;
vertical-align: top;
plunker
I think if you change display: table-cell to inline-block, you will get your expected result. of course you need margin too.
Hope this help !
Would this be a viable solution?
https://hdcs.cz/?q=node/26
The code:
<style>
.circle-blue {
width: 10px;
height: 10px;
background: deepskyblue;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.circle-gray {
width: 10px;
height: 10px;
background: gray;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.cell {
display: table-cell;
font-size: 6px;
}
</style>
<table>
<tr>
<td style="padding: 5px"><div class="circle-blue cell"></div></td>
<td style="padding: 5px"><div class="circle-gray cell"></div></td>
<td style="padding: 5px"><div class="circle-blue cell"></div></td>
</tr>
</table>
Regards,
Tomas Tudja
when I zoom out on Google Chrome, my right div goes on the next line, I'm trying to figure out what it is that I'm doing wrong. Could it be a display inline block? I'm confused here, but look:
I don't have anything in latest new id
#latestnews {
}
My Left & Right columns
.left {
width: 70px;
float: left;
margin: 3px;
height: 60px;
padding-bottom: 5px;
border: 1px solid #C2C2C2;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background: #E9E9E9;
}
.right{
float: left;
padding-left: 5px;
margin-left: 10px;
margin: 3px;
width: 491px;
height: 60px;
border: thin solid #CCC;
background: #E9E9E9;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
padding-bottom: 5px;
}
What it shows:
<div class="left" style="clear:both;">
<div class="date">
<span class="day">17</span>
<span class="month">Feb</span>
<span class="year">2014</span>
</div>
</div><!-- End Left Column -->
<div class="right">right</div>
When I zoom out, it shows this:
but on normal view, it shows this:
is it possible that I didn't include anything in my container for #latestnews ? Thanks for all help!
My guess is that the float: left style on the div you are trying to put on the right, is why you are having that problem.
Why don't you try getting rid of both float: left styles, and replace them with display: inline-block.
Then your only problem should be zooming in.