I am trying to size video containers height but for some reason, its height is unnecessarily big.
CSS:
.indexVideoContainer{
display:flex;
flex-direction: column;
background-color: #fff;
background-image: url(https://bellroy.imgix.net/cms_images/1259/background-texture-repeat.jpg?auto=format&fit=max);
width: 100%;
}
.indexVideoText{
position: relative;
font-family: "PT Serif", serif;
-webkit-font-smoothing: antialiased;
text-align: center;
margin: 5px auto 20px auto;
font-weight: 400;
/* line-height: 32px; */
color: #666;
font-weight: 500;
font-size: 25px;
line-height: 40px;
margin: 0 auto 40px auto;
max-width: 55%;
top:50px;
}
.videoContainer{
position:relative;
padding-bottom:60.25%;
padding-top:30px;
height:0;
overflow:hidden;
border:1px solid black;
}
.videoContainer iframe{
position:absolute;
margin: auto;
top: 35%;
left: 50%;
transform: translate(-50%, -50%);
width:70%;
height:60%;
}
Codepen:
https://codepen.io/anon/pen/MZNgYa
Check the .videoContainer class. I added a border for a better demonstration. Its height is unnecessarily big. Expands too much for some reason. How do I make it shorter in a responsive way?
problem image
Edit:
I still have the problem guys.I have managed to fix it with some workaround but i guess i am missing something with video frame and flexbox.
html:
<div class="indexVideoText">
sometext
</div>
<div class="videoContainer">
<iframe title="hQ6TSIFM8I0" width="80%" height="80%" frameBorder="0" src="https://www.youtube-nocookie.com/embed/hQ6TSIFM8I0?autoplay=1&loop=1&playlist=hQ6TSIFM8I0&origin=bellroy.com&modestbranding=1&showinfo=0&rel=0&version=3&mute=1"></iframe>
</div>
CSS
.indexVideoText{
position: relative;
font-family: "PT Serif", serif;
-webkit-font-smoothing: antialiased;
text-align: center;
margin: 5px auto 20px auto;
font-weight: 400;
/* line-height: 32px; */
color: #666;
font-weight: 500;
font-size: 25px;
line-height: 40px;
margin: 0 auto 40px auto;
max-width: 55%;
top:50px;
}
.videoContainer{
position:relative;
height:500px;
overflow:hidden;
border:1px solid black;
background-color:red;
padding-top:20px;
padding-bottom:20px;
}
iframe{
position:absolute;
margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width:70%;
}
Related
For some reason, my CSS file will not align my circle on the page.
This is my html object for a circle:
<div class="circle-text">Upload your photo here</div>
CSS file:
.circle-text {
display: table-cell;
height: 400px; /*change this and the width
for the size of your initial circle*/
width: 400px;
text-align: center;
vertical-align: middle;
align
border-radius: 50%;
/*make it pretty*/
background: #000;
padding-top:;
color: #fff;
font: 18px "josefin sans", arial;
}
Any ideas why?
Try to add:
.circle-text{
margin: auto
}
i think it works
.circle-text {
height: 400px; /*change this and the width
for the size of your initial circle*/
width: 400px;
line-height: 400px;
text-align: center;
vertical-align: middle;
border-radius: 100%;
position:absolute;
left:50%;
transform:translate(-50%,0);
/*make it pretty*/
background: #000;
color: #fff;
font: 18px "josefin sans", arial;}
.circle-text .txt{
line-height: 400px;
text-align: center;
vertical-align: middle;
}
<div class="circle-text"><div class="txt">
Upload your photo here</div></div>
I am trying to remove the extra margin- the orange space, and move the red dot up. Could someone please help? I have tried using the css tags- margin, padding. But, could not get it to work.
<div style="padding:0px; margin-right:0px; width: 280; font-family:Arial, Helvetica, sans-serif ;font-size: 40px; font-weight: bold;color:#33A8FF">
Current Status
</div>
<div id= "redC" style="width: 10px;
height: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: red;
margin-left: 400px
">
</div>
Use display:inline-block and vertical-align:middle; to div this will make divs in a line and vertically centered and try to avoid inline css
div {
display: inline-block;
vertical-align:middle;
}
.CurrentStatus {
padding: 0px;
margin-right: 0px;
width: 280;
font-family: Arial, Helvetica, sans-serif;
font-size: 40px;
font-weight: bold;
color: #33A8FF
}
#redC {
width: 10px;
height: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: red;
margin-left: 40px
}
<div class="CurrentStatus">
Current Status
</div>
<div id="redC">
</div>
You could use display:inline-block for the both divs.
div {display:inline-block}
This will work
<div style="padding:0px; margin-right:0px; width: 280; font-family:Arial, Helvetica, sans-serif ;font-size: 40px; font-weight: bold;color:#33A8FF; float:left">
Current Status
</div>
<div id= "redC" style="width: 10px;
height: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: red;
float:left;
margin-top:20px;
">
</div>
Method 1) Insert display: inline-block to div like this :
div {
display: inline-block;
}
Method 2) use of :after :
div {
position: relative;
padding:0px;
margin-right:0px;
width: 280px;
font-family:Arial, Helvetica, sans-serif ;
font-size: 40px;
font-weight: bold;
color:#33A8FF;
}
div:after {
content: '';
height: 10px;
width: 10px;
position: absolute;
background-color: red;
border-radius: 100%;
top: 50%;
right: -10px;
}
<div>Current Status</div>
I have 3 divs inside of the body, and I need them to stay centered at all times, without overlapping.
I would post the link to the page but it is currently being hosted locally for testing purposes.
body {
background-color: #c8dbdd;
background-image: url("http://www.splashpage.dev/wpcontent/uploads/2016/01/splashbackground.jpg");
background-position: center center;
display:inline-block;
}
#title {
left: 50%;
top: 50%;
/* bring your own prefixes */
transform: translate(-50%, -50%);
margin-top: 80px;
margin-bottom: 20px;
display:block;
position:absolute;
display:inline-block;
}
.carousel {
left: 50%;
top: 50%;
/* bring your own prefixes */
transform: translate(-50%, -50%);
height: 210px;
width: 950px;
background-color: rgba(255, 255, 255, 0.24);
position:fixed;
padding: 10px;
outline: #fff solid thin;
display:table;
clear:both;
display:inline-block;
}
.text {
font-family:'Ubuntu', sans-serif;
color: #ffffff;
font-size: 12px;
text-align:center;
margin-bottom: 3px;
line-height: 25px;
}
.bottom {
font-family:'Ubuntu', sans-serif;
position:fixed;
bottom:20px;
width:100%;
text-align:center;
color: #fff;
font-size:12px;
letter-spacing: 5px;
}
a {
color: #fff;
text-decoration: none;
}
<body>
<div id="title">
<div style="text-align: center"></div>
</div>
<div class="carousel" id="carousel">
<div class="text" id="text"><font size="4px"></div>
</div>
<div id="bottom">
<div class="bottom" style="text-align: center">
THE DESTINATIONS
THE MISSION
CONTACT
CAREERS
</div>
</div>
</body>
I have tried all kinds of position, float, clear, and margin combinations and I can get them centered but I can not keep them from overlapping.
Try the following CSS code. The display:table; line is commented and the height of the .carousel is also increased to height:442px; and the hyperlink text colour is changed to white as the background is black and it doesn't appear.
#import url(//fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
body {
background-color: #000;
background-image: url("http://www.splashpage.dev/wp-content/uploads/2016/01/splashbackground.jpg");
background-position: center center;
}
#title {
//float: center;
margin-top: 80px;
}
.carousel {
margin: 0 auto;
height: 442px;
width: 950px;
background-color: rgba(255, 255, 255, 0.24);
// position:relative;
padding: 10px;
outline: #fff solid thin;
//display: table;
}
.text {
font-family:'Ubuntu', sans-serif;
color: #000;
font-size: 12px;
text-align:center;
margin-bottom: 3px;
line-height: 25px;
}
.bottom {
font-family:'Ubuntu', sans-serif;
// position:fixed;
bottom:20px;
width:100%;
text-align:center;
color: white;
font-size:12px;
letter-spacing: 5px;
}
a {
color: white;
text-decoration: none;
}
Using html/css, I want to create a perfect circle with two lines of centered text like in the image below. What is the cleanest/most elegant way that will work in modern browsers? Do I have to declare a width and height or can I just use padding/border-radius?
Here is the JSFiddle.
HTML
<h2 class="score">92 <br>
<span class="text">Overall</span>
</h2>
CSS
.score {
font-family: Arial;
text-align: center;
background: #DCAA38;
border-radius: 50%;
padding: 15px;
font-size: 30px;
color: #fff;
margin-bottom: 0;
}
.text {
position: relative;
margin-top: -20px !important;
font-weight: 100;
font-size: 12px;
}
please see here: fiddle you need to create square first
.container {
max-width: 500px;
}
.score {
font-family: Arial;
text-align: center;
background: #DCAA38;
border-radius: 100px;
padding: 15px;
font-size: 30px;
height:100px;
width:100px;
color: #fff;
margin-bottom: 0;
}
.text {
position: relative;
margin-top: -20px !important;
font-weight: 100;
font-size: 12px;
}
You are missing the dimensions:
.score {
width:75px;
height:75px;
...
}
I made this It's two different methods one uses tables and the other uses transform.
Personally i like the second one best because i don't have to use so many divs.
.perfect-circle2 {
font-family: Arial;
font-weight: 100;
background: #222;
display: inline-block;
text-align: center;
width: 20%;
position: relative;
border-radius: 50%;
vertical-align: middle;
padding-bottom: 20%;
height: 0;
}
.content2 {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.number, .text {
display: block;
color: #FFF;
}
.number {
font-size: 200%
}
.text {
font-size: 100%;
}
To create these examples i used code from:
Vertical align
Propotional resizing
Hey like the Kai Qing said change your class like this
.score {
font-family: Arial;
text-align: center;
background: #DCAA38;
border-radius: 50%;
padding: 15px;
font-size: 30px;
color: #fff;
margin-bottom: 0;
height:70px;
width:70px
}
I have added equal height and width attributes.
For responsiveness you can use em values instead of pixels
I have the following CSS. It needs to be centered on any screen but currently it is only centered on a certain kind of screen:
#import url(http://fonts.googleapis.com/css?family=Roboto+Condensed);
html{
/* font-family: 'Roboto Condensed', sans-serif;*/
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 20;
}
#description{
position: absolute;
top: 200px;
left: 400px;
}
#content{
margin: 0 auto;
height: 100%;
width: 100%;
text-align: center;
line-height: 100%;
display:table-cell;
vertical-align: middle;
}
h1{
color:#4A4A4A;
margin: 0 auto;
text-align: center;
}
h1:hover{
color:#4A4A4A;
}
h2{
color:#4A4A4A;
margin: 0 auto;
text-align: center;
}
h2:hover{
color:#4A4A4A;
}
a{
color:black;
text-decoration: none;
margin: 0px auto;
width: 400px;
}
.circular{
display: block;
margin-left: auto;
margin-right: auto;
width: 150px;
height: 150px;
border-radius: 75px;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
background: url(./images/profile_picture.jpg) no-repeat;
box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
}
ul{
padding: 0;
text-align:center;
padding-top: 5
}
ul a img {
padding-top: 20px;
}
li{
list-style: none;
text-align: center;
font-size: 30px;
display: inline-block;
margin-right: 10px;
}
#back{
position:absolute;
top:0;
left:0;
bottom:0;
right: 0;
z-index: -99999;
background-color: #f7f7f7;
background-size: cover;
background-position: center center;
opacity: .2;
}
Currently my website only centers on a 4x3 screen. How can I adjust my CSS to center on any size screen?
Edit: Same question is here with HTML.
You have not posted your HTML code (dont know why (?))!
Well the trick to center an element with CSS is to give the element a left and right margin value of auto
#wrapper
{
width: 500px;
margin-left: auto;
margin-right: auto;
}
This is also similar to margin:0 auto which is widely used !
Wrap your content using a <div id="wrapper">...</div> and set a width !
To center an image, add display:block to it since by default the images have display:inline property.
#myImage
{
width: 50px;
height: 50px;
margin-left: auto;
margin-right: auto;
display: block;
}
Update: The answer from Magesh Kumaar is better, but this still works.
Without seeing the code on your page, it is a little difficult. But to center a DIV on any screen you should use the following code:
#divID {
position: absolute;
width:400px;
left:50%;
margin-left:-200px; /*This should always be 50% of your width*/
}
You should then wrap the rest of your website in the DIV.
<div id="divID">
YOUR WEBSITES CONTENT GOES HERE
</div>
Wrap your content, set width, and add margin: 0 auto to the wrap's css
<div id="body">
<div id="wrap">
<div id="center">Center</div>
</div>
</div>
#wrap {
margin:0 auto;
width:50%;
}
Fiddle
Firstly define the Div id in HTML as:
<div id="page">
website content
</div>
Then in CSS: set width, and add margin: 0 #page {
margin:0 auto;
width:50%;
}