I want to create a custom audio player, with basically:
a button for playing
a flexible bar, i.e., that adapts itself to the player width
a group of button at the right of the player, namely for the download button etc
For the two first parts I have no problem (see the fiddle), but it's for the second button group I have troubles.
I tried to put the group with float:right, but in this case it is kicked out from the player. Then I tried to put the flexible bar with a floating property, but in this case I have to specify its width and it becomes no more flexible.
Here is a sample image of what I want to achieve:
Here is what I have so far:
HTML:
<div class="player" style="width:500px">
<div class="group">
<a class="button" href="#"></a>
</div>
<div class="flexible">
<div class="bar"></div>
</div>
<div class="clear"></div>
</div>
CSS:
.player
{
height:24px;
background-color: #222222;
}
.player .group
{
float:left;
}
.player .group .button,
.player .group2 .button
{
display: inline-block;
width:24px;
height:24px;
background-color:#444444;
}
.player .group2
{
float:right;
}
.player .flexible
{
box-sizing:border-box;
overflow:hidden;
}
.player .flexible .bar
{
margin : 8px;
height : 8px;
background-color:#225599;
}
JSFiddle:
https://jsfiddle.net/grh7sahq/3/
Do you have any advice ?
Thanks
I understood you wanted the central part to be flexible. You can use display: flex. Really basic CSS to show it:
.player{
background: black;
height: 100px;
display: flex;
}
.button{
background: blue;
height: 100px;
width: 24px;
display: block;
}
.flexible{
flex: 1;
}
<div class="player" style="width:500px">
<div class="group">
<a class="button" href="#"></a>
</div>
<div class="flexible">
<div class="bar"></div>
</div>
<div class="group2">
<a class="button" href="#"></a>
</div>
</div>
<br/>
<div class="player" style="width:150px">
<div class="group">
<a class="button" href="#"></a>
</div>
<div class="flexible">
<div class="bar"></div>
</div>
<div class="group2">
<a class="button" href="#"></a>
</div>
</div>
change this css class to use inline style...
.player .group .button,
.player .group2 .button
{
display: inline;
width:24px;
height:24px;
background-color:#444444;
}
DEMO
It is actually pretty simple with flex box
<div class="player">
<div class="button"></div>
<div class="seek">
<div></div>
</div>
<div class="button"></div>
<div class="button"></div>
</div>
CSS
.player{
height: 35px;
background-color: #555;
display: flex;
}
.player>.button{
width: 35px;
}
.player>.seek{
padding: 10px;
flex-grow: 1;
}
.player>.seek>div{
background-color: #0af;
height: 100%;
}
Related
hi will be available in the shape of circle. I got the code for responsive circle with text but the problem is this hat i am not able to inline two circles in one line . I tried float:left; as well as display:inline-block; but both doesn't work for me. Display:inline-block; inline the circles but the text inside it overlaps.
THIS is my HTML:
/*------NAV--BAR--*/
* .fa-navicon{padding:8px; font-size:7vw ;}
.nav-bar{position:absolute;z-index:5;width:100%; height:100%; background:grey; padding:10px;}
.nav-bar input{ border:; outline:none; margin-left:10px;
width:70%;
}
.nav-bar input::placeholder{color:grey; margin-left:10px;}
/*--copied-code---*/
.circle {
position: relative;
display: block;
margin: 2em 0;
background-color: transparent;
color: #222;
text-align: center;
}
.circle:after {
display: block;
padding-bottom: 30%;
width: 30%;
height: 0;
border-radius: 50%;
background-color: #ddd;
content: "";
}
.circle__inner {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 30%;
height: %;
}
.circle__wrapper {
display: table;
width: 100%;
height: 100%;
}
.circle__content {
display: table-cell;
padding: 1em;
vertical-align: middle;
}
#media (min-width: 480px) {
.circle__content {
font-size: 2em;
}
}
#media (min-width: 768px) {
.circle__content {
font-size: 4em;
}
}
}
<div class="nav-bar">
<input type="search" placeholder="Search...">
<i class="fa fa-close " style="font-size:7vw;color:#393e41; padding:3px; vertical-align:top; "></i>
<div class="option-wrapper">
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">Global</div>
</div>
</div>
</div>
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">Friends</div>
</div>
</div>
</div>
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">Classroom</div>
</div>
</div>
</div>
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">Games</div>
</div>
</div>
</div>
</div>
</div>
I want two or three circles on every line depending upon the user screen size.
Sorry if i did something wrong. This is my first quest. in stackoverflow.Thnks in advance.
Check this, adjust the browser size to view the responsiveness. You can also change the circle dimensions and font size depending upon your media-size.
If you need the full site to be responsive, I suggest to implement it with the popular CSS framework "Bootstrap", its pretty easy - Bootstrap-Grid-HowItworks
.fa-navicon{padding:8px; font-size:7vw ;}
.nav-bar{position:absolute;z-index:5;width:100%; height:100%; background:grey; padding:10px;}
.nav-bar input{ border:; outline:none; margin-left:10px;
width:70%;
}
.nav-bar input::placeholder{color:grey; margin-left:10px;}
.circle-wrapper {
float: left;
margin: 10px;
}
.circle {
display: table-cell;
text-align: center;
vertical-align: middle;
border-radius: 50%;
background: #f2f2f2;
border-spacing: 10px;
}
#media (min-width: 480px) {
.circle{
height: 150px;
width: 150px;
font-size: 30px;
}
}
#media (min-width: 768px) {
.circle {
height: 150px;
width: 150px;
font-size: 30px;
}
}
<div class="nav-bar">
<input type="search" placeholder="Search...">
<i class="fa fa-close " style="font-size:7vw;color:#393e41; padding:3px; vertical-align:top; "></i>
<div class="option-wrapper">
<div class="circle-wrapper">
<div class="circle">Global</div>
</div>
<div class="circle-wrapper">
<div class="circle">Friends</div>
</div>
<div class="circle-wrapper">
<div class="circle">Classroom</div>
</div>
<div class="circle-wrapper">
<div class="circle">Games</div>
</div>
<div class="circle-wrapper">
<div class="circle">School</div>
</div>
<div class="circle-wrapper">
<div class="circle">College</div>
</div>
</div>
</div>
I'm trying to get everything in my header to get centered in the header table, but I can't figure out how. I managed to get it centered vertically but I can't figure out how to get it centered horizontally. Can you please tell me how to do it? https://fiddle.jshell.net/rgfxs94L/2/
<div id="header">
<div class="center">
<div class="header_cells">
<img onclick="get_page('?page=home');" title="logo" id="logo" src="http://www.rajohan.no/img/logo_small.png">
</div>
<div id="main_buttons" class="header_cells">
<div id="home" class="header_cells">
<Home>
</div>
<div id="cv" class="header_cells">
<CV>
</div>
<div id="nyheter" class="header_cells">
<Nyheter>
</div>
<div id="movie" class="header_cells">
<Film>
</div>
<div id="games" class="header_cells">
<Spill>
</div>
<div id="music" class="header_cells">
<Musikk>
</div>
</div>
<div class="header_cells">
<form id="search_form">
<input type="search" id="search_box" placeholder="Søk...">
</form>
</div>
</div>
</div>
#header {
border-top: 3px solid #e87f29;
background-color: #f8f8f8;
min-width: 100%;
min-height: 100%;
position: static;
border-bottom: 1px solid #e8e8e8;
display: table;
}
.center {
text-align: center;
}
.header_cells {
display: table-cell;
min-height: 100%;
min-width: 100%;
vertical-align: middle;
}
#logo {
width: auto;
max-height: 40%;
}
Use inline-block instead:
https://fiddle.jshell.net/o4u8per4/
.header_cells {
display:inline-block;
vertical-align: middle;
}
I'd like to position all my text vertically centered within the div.
Currently 'Chat to us online now' is at the top of the div.
How do I achieve this using my code?
Fiddle: http://jsfiddle.net/jL5bpmp1/
* {
margin:0
}
.box {
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
background-color:#0f89cf;
height:55px;
width:100%;
padding:5px 0 0 0;
margin-bottom:30px
}
.box img, .box div {
float:left;
margin-left:10px
}
.box h1 {
color:#fff;
font-size:18px
}
.box h1 span {
display:block;
font-size:23px
}
<div class="is-mobile">
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Chat to us online now</h1>
</div>
</div>
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Call the Helpline
<span>101 2333 9302</span></h1>
</div>
</div>
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Make a General Enquiry
<span>101 2333 9303</span></h1>
</div>
</div>
</div>
I suggest to use display:inline-block instead of float:left, then you can set up the vertical align value easily.
.box img, .box div {
display:inline-block;
vertical-align:middle;
}
jsfiddle
You can use this common vertical centering method:
.box div {
position: relative;
top: 50%;
transform: translateY(-50%);
}
* {
margin:0
}
.box {
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
background-color:#0f89cf;
height:55px;
width:100%;
padding:5px 0 0 0;
margin-bottom:30px
}
.box img, .box div {
float:left;
margin-left:10px
}
.box h1 {
color:#fff;
font-size:18px
}
.box h1 span {
display:block;
font-size:23px
}
.box div {
position: relative;
top: 50%;
transform: translateY(-50%);
}
<div class="is-mobile">
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Chat to us online now</h1>
</div>
</div>
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Call the Helpline
<span>101 2333 9302</span></h1>
</div>
</div>
<div class="box">
<img src="http://placehold.it/50x50">
<div>
<h1>Make a General Enquiry
<span>101 2333 9303</span></h1>
</div>
</div>
</div>
If your browser support is IE10+ you can use flex-box. You just need to add 2 lines:
.box {
display: flex;
align-items: center;
padding: 0;
}
I also added padding: 0; as you don't need that now you're using flex-box. Welcome to the future. The best place to learn about flexbox is here:
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
I have some problems with my DIV table.. maybe there is a better way to do this.
I want to have all columns to be the same height as the highest column. Is there a way to do it? or is there another way to make this work ?
I have to made a jsfiddle example here with my code: http://jsfiddle.net/rb500o4L/ (right column is higher than left, middle and the logo column.)
My CSS code:
div.round-border {
border: solid 1px;
border-color: #002F67;
border-radius: 10px;
}
#container {
display: table;
width: 100%;
}
#row {
display: table-row;
}
#cell {
display: table-cell;
}
#cell-logo {
display: table-cell;
width: 200px;
}
My HTML code:
<div id="container">
<div id="row">
<div id="cell">
<div class="round-border">
<h4>Left Col</h4>
<p>...</p>
</div>
</div>
<div id="cell">
<div class="round-border">
<h4>Middle Col</h4>
<p>...</p>
</div>
</div>
<div id="cell">
<div class="round-border">
<h4>Right Col</h4>
<p>...</p>
<p>...</p>
</div>
</div>
<div id="cell-logo">
<div class="round-border">
<h4>LOGO AREA</h4>
<p>...</p>
</div>
</div>
</div>
</div>
I appreciate any recommendation.
use this css
div.round-border {
border: solid 1px;
border-color: #002F67;
border-radius: 10px;
}
container {
width: 100%;
}
row {
height:auto;
}
#cell
{
height:auto;
min-height:400px;
width:50px;
display:inline-block;
}
#cell-logo {
width: 50px;
}
When i do my web design, meet a problem when i need to do
[LEFT LOGO] then [TITLE(CENTER)] then [RIGHT LOGO]
The problem appear at RIGHT LOGO there, it doesn't align with LEFT LOGO.
The right logo is under the line of TITLE(CENTER)
here is my code sample, thanks:
<div class="navigation">
<div id="left">
<a title="Multimedia" href="#">
<img src="images/logo.png"/>
</a>
</div>
<div id="title">Tutor Program</div>
<div id="right">
<a href="#" title="Inspire and Innovate">
<img src="images/tagline_alt.png"/>
</a>
</div>
css:
.navigation{
height:auto;
background-color:#666;
width:85%;
margin:auto;
min-width:800px;
}
#title{
text-align:center;
margin: auto;
font-family:‘Arial Black’, Gadget, sans-serif;
font-size: 20px;
color: #FFF;
}
#left {
float: left;text-align:left;
margin: auto;
}
#right {
float: right;text-align:right;
margin: auto;
}
a img { border: 0; }
simply move the right container above the left container check below
<div class="navigation">
<div id="right">
<a href="#" title="Inspire and Innovate">
<img src="images/tagline_alt.png"/>
</a>
</div>
<div id="left">
<a title="Multimedia" href="#">
<img src="images/logo.png"/>
</a>
</div>
<div id="title">Tutor Program</div>
</div>
I thing its work an another way i have some changes in style width depends of logo width. if it is not set in center then change the width %.
#title{
text-align:center;
margin: auto;
font-family:'Arial Black', Gadget, sans-serif;
font-size: 20px;
color: #FFF;
width:59%;
float:left;
}
.clear {
clear:both;
margin:0px;
font-size:0px;
}
and add a div after the last div with class clear.
<div id="right"> .... </div>
<div class="clear"> </div>
You could also display your divs as a table and table-cells, like this:
HTML
<div class="navigation">
<div id="left">
left
</div>
<div id="title">
title
</div>
<div id="right">
right
</div>
</div>
CSS
.navigation {
width: 100%;
display: table;
table-layout: fixed;
}
.navigation > div {
display: table-cell;
}
.navigation div:nth-child(1) {
background: lightgray;
}
.navigation div:nth-child(2) {
background: gray;
text-align: center;
}
.navigation div:nth-child(3) {
background: lightgray;
text-align: right;
}
Also check the JSFiddle Demo