The error specifically is that the span element has a width of 900 pixels and it forces the page to scroll horizontally due to it extending so far at smaller screen sizes. I tried using the overflow: hidden property but that does not stop the scrolling.
The reason why I need 900 pixels is so my text and borders are centered and my border doesn't split into two parts. In addition, this text is over a carousel slider of images. The error looks as such:
http://i.imgur.com/iAd16ml.png
My goal is to crop the page's width where the element overextends at. This is my code:
`
#title-display{
vertical-align: middle;
text-align: center;
justify-content: center;
position: absolute;
top: 50%;
left: 50%;
margin: -40px 0 0 -450px;
}
#title-display span{
width: 900px;
float: left;
position: absolute;
}
#title-display h1 {
display: inline;
text-transform: uppercase;
border-width: 8px;
border-style: solid;
border-color: white;
padding: 10px;
color: white;
font-size: 4vw;
}
`
I use margin: -40px 0 0 -450px; to center the text.
Here is some html in case:
<div id="title-display">
<span>
<h1><strong>Adrian's Workflow<strong></h1>
<p class="kicker">Designer // Programmer // Youtuber</p>
</span>
</div>
You could position the #title-display element at 50%, 50% then use transform: translate(-50%, -50%) to offset it by half its width and height regardless of its actual size. Like so.
body {background:#666;}
#title-display{
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align:center;
}
#title-display h1 {
text-transform: uppercase;
border-width: 8px;
border-style: solid;
border-color: white;
padding: 10px;
color: white;
font-size: 4vw;
white-space: nowrap;
}
<header id="title-display">
<h1><strong>Adrian's Workflow</strong></h1>
<p class="kicker">Designer // Programmer // Youtuber</p>
</header>
Related
I am learning css and working on a project where I need to display a rounded ribbon at the bottom right corner of the web page along with icon and text in it. Below is the screenshot of the design that I am trying to achieve..
So far I am able to display the ribbon but unable to keep the icon and text normal. Here is the link to Codepen: https://codepen.io/stephen0roper/pen/JeKdJV
CSS Code:
/* The ribbons */
.corner-ribbon{
font-weight: bold;
width: 50px;
background: #e43;
position: absolute;
bottom: 5px;
right: -30px;
text-align: left;
line-height: 100px;
letter-spacing: 1px;
color: #f0f0f0;
transform: rotate(5deg);
-webkit-transform: rotate(5deg);
border-radius: 65px;
}
/* Custom styles */
.corner-ribbon.sticky{
position: fixed;
}
.corner-ribbon.shadow{
box-shadow: 0 0 3px rgba(0,0,0,.3);
}
/* Different positions */
.corner-ribbon.top-left{
bottom: -50px;
right: -100px;
transform: rotate(-270deg);
-webkit-transform: rotate(-315deg);
background-color: red;
width: 226px;
height: 125px;
}
.corner-ribbon.red{background: #e43;}
Hi this is how I solved this puzzle:
1 remove the line-height:100px; in .corner-ribbon class
2 wrap the text and icon into a div and add a class"stop-rotate", and justneed to rotate it back 45deg:
.stop-rotate{
display:inline;
padding-top:30px;
float:left;
transform: rotate(-45deg);
text-align:center;
}
3 edit the html tags, and change the icon to fa-2x
<div class="corner-ribbon top-left sticky red shadow">
<div class="stop-rotate">Some text
<i class="fas fa-camera fa-2x" style="display:block"></i>
</div>
</div>
I have saved the Pen(for those who may need: https://codepen.io/anon/pen/OaRpOd ),you may still see the result and may need to edit the size a little bit.
Hope this helps.:)
please look at this:
https://codepen.io/anon/pen/aQmJjy?editors=1100
/* The ribbons */
.corner-ribbon {
font-weight: bold;
width: 50px;
background: #e43;
position: absolute;
bottom: 5px;
right: -30px;
text-align: center;
line-height: 40px;
letter-spacing: 1px;
color: #f0f0f0;
transform: rotate(5deg);
-webkit-transform: rotate(5deg);
border-radius: 65px;
}
/* Custom styles */
.corner-ribbon.sticky {
position: fixed;
}
.corner-ribbon.shadow {
box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}
/* Different positions */
.corner-ribbon.top-left {
bottom: -50px;
right: -100px;
transform: rotate(-270deg);
-webkit-transform: rotate(-315deg);
background-color: red;
width: 226px;
height: 125px;
}
.corner-ribbon.red {
background: #e43;
}
.rotate-text {
transform: rotate(270deg);
-webkit-transform: rotate(315deg);
position: absolute;
left: 15px;
top: 0;
font-family: sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
item-align: center;
height: 120px;
}
<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet" />
<div class="corner-ribbon top-left sticky red shadow">
<div class="rotate-text">
<span>Some text</span>
<i class="fas fa-camera fa-2x"></i>
</div>
</div>
I have a problem that's driving me insane, and it has done so for quite some time. I've spent days trying to figure this one out with no success. Google is basically purple to me now. Additionally I fear the answer might be embarrassingly easy - but I'm about to go drown myself so here goes:
The problem:
I use pure css modal windows on my site. They are set to be absolutely positioned using margin: 0 auto; and translateY(-50%); like so:
margin: 0px auto;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
I am using named anchors to hide/show the modal windows.
This works beautifully in basically every browser - I get the modal windows to appear and disappear like they are supposed to, in the center of the VIEWPORT of my browser window. In Safari and on iPhones and iPads however, it seems my modal windows get absolutely centered relative to the ENTIRE PAGE/DOCUMENT.
So, if my page has a vertical scrollbar, clicking the anchor link and showing the modal window makes the BROWSER WINDOW jump as well - in order to display the modal window in the absolute center of the entire page.
I include my modal windows just before the closing body tag like so:
<?php
include 'layout/elements/modal/users_online.php';
include 'layout/elements/modal/requests.php';
include 'layout/elements/modal/notifications.php';
include 'layout/elements/modal/messages.php';
include 'layout/elements/copyright.php';
include 'layout/elements/modal/developer.php';
?>
</body>
</html>
This is the code of my modal windows:
.modal {
display: none;
position: fixed;
z-index: 9999;
width: 100%;
height: 100%;
top: 50%;
left: 0;
color: #333333;
}
.modal:target {
display: block;
outline: none;
}
.modal .big_container {
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
width: 785px;
height: 515px;
margin: 0px auto;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
padding: 20px;
background-color: #ffffff;
box-shadow: 0px 1px 26px -3px #777;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
text-align: center;
}
So thanks to weBer (seriously thank you so much :D) I was able to figure out the answer.
This works:
.modal {
display: none;
position: fixed;
z-index: 9999;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.modal:target {
display: block;
outline: none;
}
.modal .big_container {
position: fixed;
display: block;
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
min-width: 785px;
max-width: 785px;
min-height: 515px;
max-height: 515px;
margin: 0px auto;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
padding: 20px;
background-color: #ffffff;
box-shadow: 0px 1px 26px -3px #777777;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
text-align: center;
}
Am not sure this is your answer but here it goes.
Am taking .modal as your pop up overlay background. So change its code to -
.modal {
display: none;
position: fixed;
z-index: 9999;
width: 100%;
height: 100%;
top: 0;
left: 0;
color: #333333;
}
And .modal .big_container- which is our content box should have the following style.
.modal .big_container {
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
width: 785px;
height: 515px;
display:inline-block;
position:absolute;
left:50%;
top:50%;
-webkit-transform: translateY(-50%,-50%);
-ms-transform: translateY(-50%,-50%);
transform: translateY(-50%,);
padding: 20px;
box-sizing:border-box;
background-color: #ffffff;
box-shadow: 0px 1px 26px -3px #777;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
text-align: center;
}
Check if it works for. I think this might, I use this in my most of the projects.
I have a form with these tags: <form>, <fieldset> and <legend>.
The fieldset's border passes through the middle of the legend element. I still want to have the border around my form, but I don't want to pass through the middle of it.
The problem is like this: if I try in css only the fieldset and the legend, everything works fine, but if I also add the form style I get the error I'm talking about.
.form {
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
min-height: 50px;
padding: 5px;
margin: 10px;
clear: both;
float: left;
width: 40%;
text-align: left;
border: 0px;
}
fieldset {
padding: 10px;
margin: 2px;
border: 1px solid #000000;
width: 60%;
}
legend {
padding: 0px;
border: 0px;
color: #ff0000;
text-transform: capitalize;
font-size: 14px;
font-weight: bold;
display: inline-block;
}
<form>
<fieldset>
<legend>Title</legend>
</fieldset>
</form>
I guess it's a conflict between form and fieldset/legend styling. The reason I've added position: absolute; and the translate method is to position the form in the middle of the browser's page.
So, how can I get rid of the border's fieldset passing through the middle of the legend, but still positioning my form in the center of the page?
form legend{ position:relative; z-index:2 }
If you want the legend to appear outside of the fieldset border, you will have to place it before the fieldset element, not within it. This is not valid HTML, however, so use it at your own risk.
form {
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
min-height: 50px;
padding: 5px;
margin: 10px;
clear: both;
float: left;
width: 40%;
text-align: left;
border: 0px;
}
fieldset {
padding: 10px;
margin: 2px;
border: 1px solid #000000;
width: 60%;
}
legend {
padding: 0px;
border: 0px;
color: #ff0000;
text-transform: capitalize;
font-size: 14px;
font-weight: bold;
display: inline-block;
}
<form>
<legend>Title</legend>
<fieldset>
</fieldset>
</form>
I need to build a circle shape (in css) which has 2 lines of text that could change in length based on translation selected and always centered.
So far I have this:
h3 {
background-color: #fcd141;
border-radius: 50%;
padding: 12px 5px 5px 5px;
margin-top: 30px;
width: 20%;
height: 20%;
}
<h3>
<span style="vertical-align: middle;">98%</span>
<span style="margin-top: -4px; display: block;">Ratingfasdasfasfsad</span>
</h3>
The circle needs to respond dynamically to the length of the text keeping the aspect ration intact.
You can have a look at the code as in your code it looks like an ellipse to me
.circle-text {
width: 50%;
padding 10px;
}
.circle-text:after {
content: "";
display: block;
width: 100%;
height: 0;
padding-bottom: 100%;
background: #4679BD;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.circle-text div {
float: left;
width: 100%;
padding-top: 50%;
line-height: 1em;
margin-top: -0.5em;
text-align: center;
color: white;
}
<div class="circle-text">
<div>I'm asddddddssssssssssssssssssasdasdashd asfafjsldfashdfisdpf sdjf pe!</div>
</div>
You could use vw (view width units) for this:
note
transform is used for vertical alignment only.
h3 {
background-color: #fcd141;
border-radius: 50%;
padding: 20px;
margin-top: 30px;
width: 20vw;
height: 20vw;
text-align: center;
word-wrap: break-word;
position: relative;
}
h3 span {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h3>
<span> 98% <br />
Ratingfasdasfasfsad</span>
</h3>
I was also able to remove your inline styling, and combined your two spans into one.
So I have this thing popup-window on my homepage that I fill with some content. The problem I'm having with it is that it's resizeing way to early.
I don't want the popup to resize before getting to big for the window to handle.
How am I going to solve this? Been at it for some time, can't figure it out.
You can try it out in the jsiffle url, resize the width of the preview window and you'll see it shrinks before it's even needed.
http://jsfiddle.net/82gvnamL/
CSS:
#popup {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.75);
z-index: 2;
}
#popup #loading {
height: 32px;
width: 32px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
background: url('../img/ajax-loading.gif') no-repeat;
background-size: 32px 32px;
display: inline-block;
}
#popup #container {
max-width: 95%;
max-height: 95%;
padding: 10px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
background: #111;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
border-radius: 10px 10px 10px 10px;
}
#popup #content {
width: 100%;
font-family: 'Oxygen', sans-serif;
font-size: 12px;
color: #ccc;
text-align: left;
line-height: 16px;
}
#popup #close {
width: 20px;
height: 16px;
padding: 4px 0 0 0;
border: 1px solid #333;
border-radius: 50%;
float: right;
background: #222;
position: absolute;
top: -7px;
right: -7px;
font-family: 'Nunito', sans-serif;
font-size: 12px;
text-align: center;
color: #fff;
line-height: 12px;
cursor: pointer;
}
#popup #close:before {
content: 'X';
}
HTML:
<div id="popup">
<div id="container">
<div id="close"></div>
<div id="content">
<p>Very long string in here that should not get cut off until window width is too small. If you understand what I'm saying.</p>
</div>
</div>
</div>
Try changing the container's width like so"
#popup #container {
max-width: 255px;
width: 75%;
}
So on larger screens it will be a fixed width of 255px and on smaller screens it will shrink to 75% width.