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.
Related
Please see my codes below:
.spl-user-chatbox {
position: absolute;
width: 220px;
height: 220px;
background-color: #2196f3;
top: 50%;
overflow: hidden;
left: 50%;
border-radius: 10px;
transform: translate(-50%, -50%);
}
.spl-chatbox-hrd {
position: absolute;
background-color: #ffffff;
top: 105px;
left: 0px;
right: 0px;
bottom: 0px;
min-height: 100%;
height: 100%;
z-index: 1;
/* overflow: hidden; */
border-radius: inherit;
box-shadow: 0 2px 12px -4px rgb(0 0 0 / 20%);
}
<div class="spl-user-chatbox">
<div class="spl-chatbox-hrd">
<div class="spl-chatbox-close"></div>
<div class="spl-chatbox-hrd-uName">Text</div>
</div>
</div>
Hi, guys just asking how can I remove the color blue on the bottom
part. I'm so confused why still the color showing even I've added a
white background in the first place. Can anyone help me with this?
Thanks
You can try with background-color:transparent
I think you can set the width and hight to bigger values
.spl-user-chatbox {
width: 300px;
height: 300px;
position: absolute;
background-color: #2196f3;
top: 50%;
overflow: hidden;
left: 50%;
border-radius: 10px;
transform: translate(-50%, -50%);
}
.spl-chatbox-hrd {
position: absolute;
background-color: #ffffff;
top: 105px;
left: 0px;
right: 0px;
bottom: 0px;
min-height: 200%;
z-index: 1;
/* overflow: hidden; */
border-radius: inherit;
box-shadow: 0 2px 12px -4px rgb(0 0 0 / 20%);
}
<div class="spl-user-chatbox">
<div class="spl-chatbox-hrd">
<div class="spl-chatbox-close"></div>
<div class="spl-chatbox-hrd-uName">Text</div>
</div>
</div>
If you're not going to see the border-radius at the bottom two corners, just remove those two and only add a border-radius to the top two corners.
Add border-radius: 10px 10px 0px 0px; to the .spl-user-chatbox
.spl-user-chatbox {
position: absolute;
width: 220px;
height: 220px;
background-color: #2196f3;
top: 50%;
overflow: hidden;
left: 50%;
border-radius: 10px 10px 0px 0px; /* only add border-radius to the top two corners */
transform: translate(-50%, -50%);
}
.spl-chatbox-hrd {
position: absolute;
background-color: #ffffff;
top: 105px;
left: 0px;
right: 0px;
bottom: 0px;
min-height: 100%;
height: 100%;
z-index: 1;
/* overflow: hidden; */
border-radius: inherit;
box-shadow: 0 2px 12px -4px rgb(0 0 0 / 20%);
}
<div class="spl-user-chatbox">
<div class="spl-chatbox-hrd">
<div class="spl-chatbox-close"></div>
<div class="spl-chatbox-hrd-uName">Text</div>
</div>
</div>
you can do that :
.spl-user-chatbox {
position: absolute;
width: 220px;
height: 220px;
background-color: #2196f3;
top: 50%;
left: 50%;
border-radius: 10px;
transform: translate(-50%, -50%);
}
.spl-chatbox-hrd {
position: absolute;
background-color: #ffffff;
top: 105px;
left: -1px;
border-radius: 15px;
width: calc(100% + 2px);
min-height: calc(100% + 2px);
z-index: 1;
}
<div class="spl-user-chatbox">
<div class="spl-chatbox-hrd">
<div class="spl-chatbox-close"></div>
<div class="spl-chatbox-hrd-uName">Text</div>
</div>
</div>
This seems to only occur when the user zooms the page in the browser. I don't think you can avoid this without adding a white 1px border to the white element, it seems to be a browser quirk. As long as there is no zooming going on, nobody will notice.
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.
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>
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.
I'm making an overlay window thing and I'm trying to vertically center the message in the center of the screen.... this is my CSS thus far:
#overlay {
position: fixed;
right: 0;
left: 0;
width: 276px;
margin: 0px auto;
padding: 12px 16px;
font-size: 14px;
color: #6d748b;
background-color: #fff;
border: 2px solid #b9c1d6;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
z-index: 7500;
}
This is one way (assuming you're only trying to center one element):
#overlay {
top: 50%;
-ms-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: tranlslateY(-50%);
transform: translateY(-50%);
}
Updated fiddle