Why is my website's CSS code not responsive in bootstrap studio? - html

I have made my website in Bootstrap Studio with HTML and CSS
This is what my website looks like on PC:
I have tried to use #media to scale a box up when it is viewed on mobile:
.container_a {
text-align: left;
padding: 0px;
padding-left: 0px;
margin: 0px;
padding-right: 0px;
color: #fafafa;
background: #000000;
padding-bottom: 0px;
border: 2.4px solid #999;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
height: 33%;
width: 30%;
}
.container_a {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
#media (min-width: 768px) {
container_a {
text-align: left;
padding: 0px;
padding-left: 0px;
margin: 0px;
padding-right: 0px;
border-radius: 10 px;
color: #fafafa;
background: #000000;
padding-bottom: 0px;
border: 2.4px solid #999;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
height: 33%;
width: 30%;
}
}
#media (min-width: 320px) and (max-width: 768px) {
container_a {
width: 80%;
height: 35%;
}
}
But it doesn't work:
Why does it not work?

This does not answer your question, since it's typo related and will be closed, but you can really reduce your CSS to something more manageable since you have a bunch of redundant code:
.container_a {
text-align: left;
padding: 0;
margin: 0;
color: #fafafa;
background: #000000;
border: 2.4px solid #999;
/* Shorthand for border-radius */
border-radius: 7px 7px 0 0;
position: absolute;
top: 50%;
left: 50%;
/* combine into the translate shorthand */
transform: translate(-50%, -50%);
/* Put your mobile styles here */
width: 80%;
height: 35%;
}
#media (min-width: 768px) {
.container_a {
/* Only add the properties that change */
height: 33%;
width: 30%;
}
}

Related

Center responsive absolutely positioned element with fixed margins

I have an absolutely positioned CSS banner that has a responsive width and height based on viewport size. The element is centered on desktop and tablet devices, but not on mobile (when the banner's width starts to shrink).
I can't use the classic margin: 0 auto; trick because the margins have to be set to a fixed value for the banner to work.
The code is below:
HTML:
<h1 class="banner">A Simple CSS Banner</h1>
CSS:
#import url(https://fonts.googleapis.com/css?family=Rye);
body
{ background: #eee; }
.banner {
position: absolute;
left: 50%;
display: block;
margin: 100px -200px;
width: 400px;
max-width: calc(100% - 150px);
height: 60px;
border: 1px solid #8a1;
font: normal 30px/60px 'Rye';
text-align: center;
color: #451;
background: #9b2;
border-radius: 4px;
box-shadow: 0 0 30px rgba(0,0,0,.15) inset,
0 6px 10px rgba(0,0,0,.15);
}
.banner::before,
.banner::after {
content: '';
position: absolute;
z-index: -1;
left: -70px;
top: 24px;
display: block;
width: 40px;
height: 0px;
border: 30px solid #9b2;
border-right: 20px solid #791;
border-bottom-color: #94b81e;
border-left-color: transparent;
transform: rotate(-5deg);
}
.banner::after {
left: auto;
right: -70px;
border-left: 20px solid #791;
border-right: 30px solid transparent;
transform: rotate(5deg);
}
#media (max-width: 475px) {
.banner {
height: 90px;
line-height: 45px;
}
.banner::before,
.banner::after {
border-width: 45px;
border-right-width: 30px;
}
.banner::after {
border-left-width: 30px;
border-right-width: 45px;
}
}
Link to working codepen: https://codepen.io/Adam0410/pen/QZOKdV
Thanks for the help!
Check if this helps you.
#import url(https://fonts.googleapis.com/css?family=Rye);
body {
background: #eee;
}
.banner {
position: absolute;
left: 50%;
transform: translate(-50%);
display: block;
margin: 100px 0;
width: 400px;
max-width: calc(100% - 150px);
min-height: 60px;
}
.banner span {
display: block;
position: relative;
z-index: 1;
border: 1px solid #8a1;
font: normal 30px/60px "Rye";
text-align: center;
color: #451;
background: #9b2;
border-radius: 4px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.15) inset, 0 6px 10px rgba(0, 0, 0, 0.15);
}
.banner::before,
.banner::after {
content: "";
position: absolute;
z-index: -1;
left: -70px;
bottom: -24px;
display: block;
width: 40px;
height: 0px;
border: 30px solid #9b2;
border-right: 20px solid #791;
border-bottom-color: #94b81e;
border-left-color: transparent;
transform: rotate(-5deg);
}
.banner::after {
left: auto;
right: -70px;
border-left: 20px solid #791;
border-right: 30px solid transparent;
transform: rotate(5deg);
}
#media (max-width: 475px) {
.banner {
min-height: 90px;
line-height: 45px;
}
.banner::before,
.banner::after {
border-width: 45px;
border-right-width: 30px;
}
.banner::after {
border-left-width: 30px;
border-right-width: 45px;
}
}
<h1 class="banner"><span>A Simple CSS Banner</span></h1>
You can simply use Media queries and adapt Width and margin.
something like:
media (max-width: 475px) {
.banner{
width: 200px;
margin:100px -100px;
}
}
This way you keep the top and bottom margin:
left: 0; right: 0;
margin: 100px auto;
If you want to center an absolute or fixed element you should :
position: absolute;
left: 0%;
right:0%;
margin: 0 auto;

Making images more responsive relative to a non background image. Resize and stuck in a fixed position

I need help making my icons around the main wheel be more responsive to the page size increasing and decreasing. Right now they move around and I need them to stay put relevant to the middle wheel. I also would like the wheel and icons to resize better when the page shrinks or grows. I feel like it has something to do with my positioning but I am not sure. Been stuck for hours. Anything helps!
My website is www.marshalllanning.com and I will put my CSS code below...
.bg {
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
z-index: 0;
}
.navbar-custom {
background-color: black;
z-index: 3;
}
.navbar-brand
{
position: absolute;
width: 100%;
left: 0;
text-align: center;
margin: 0;
}
.navbar-toggle {
z-index:3;
}
.navbar-custom .navbar-toggle .icon-bar {
background-color: red;
}
.navbar-custom .navbar-toggle {
background-color: white;
}
#media screen and (max-width: 1024px) { /* Specific to
this particular image */
.bg {
left: 50%;
margin-left: -512px; /* 50% */
}
}
.img1 {
border-radius: 50%;
display: block;
margin-left: auto;
margin-right: auto;
width: 500px;
height: 500px;
border-color: white;
border-width: 15px;
border-style: solid;
position: absolute;
margin: 0;
top: 52%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 1;
}
.fb {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 30%;
left: 34%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.fb:hover {
opacity: 0.7;
}
.sc {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
position: absolute;
margin: 0;
top: 16.8%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.sc:hover {
opacity: 0.7;
}
.gh {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 30%;
left: 66%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
background-color: white;
border-color: black;
border-width: 1px;
border-style: solid;
}
.gh:hover {
opacity: 0.7;
}
.ig {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 83%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.ig:hover {
opacity: 0.7;
}
.li {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 50%;
left: 30%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.li:hover {
opacity: 0.7;
}
.xb {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 50%;
left: 70%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.xb:hover {
opacity: 0.7;
}
.az {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 70%;
left: 66%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.az:hover {
opacity: 0.7;
}
.gc {
border-radius: 20%;
display: block;
margin-left: auto;
margin-right: auto;
width: 64px;
height: 64px;
position: absolute;
margin: 0;
top: 70%;
left: 34%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 2;
border-color: black;
border-width: 1px;
border-style: solid;
}
.gc:hover {
opacity: 0.7;
}
.center {
color: whitesmoke;
height: 10em;
position: absolute;
margin: 0;
top: 30%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
Create a div around all items like <div style="width: 500px;height: 500px;position: relative;margin: auto;"> and then change in css the top and the left values.

Can't make a div overlap another specific div

I have two elements a nav div and a slide controller div, but I just cannot make the nav div overlap the slide controller div. Here is my code (1. Nav code 2. Slide controller code):
nav {
position: absolute;
width: 200px;
height: 100vh;
background-color: white;
margin-top: -20px;
z-index: 1;
}
nav ol {
margin-top: 100px;
width: 190px;
}
nav li{
display: block;
margin: 0px;
padding: 15px;
position: relative;
width: 170px;
border-bottom: 1px solid #bfbebe
}
nav a {
color: black;
}
#Slider_Control {
position: absolute;
z-index: 2;
width: 210px;
height: 40px;
background-color: #d51200;
margin-left: 50%;
transform: translate(-50%);
-webkit-transform: translate(-50%);
-ms-transform: translate(-50%);
margin-top: 574px;
}
.CircleControl {
width: 10px;
height: 10px;
display: inline-block;
background: white;
border-radius: 100%;
margin-right: 5px;
margin-left: 5px;
}
#Circles {
text-align: center;
height: 40px;
line-height: 40px;
}
#Arrow_1, #Arrow_2 {
position: absolute;
width: 20px;
height: 0 auto;
margin-top: -40px;
padding: 10px;
background: #ed1602
}
#Arrow_2 {
margin-left: 170px;
transform: rotate(180deg);
}
#Triangle_1 {
width: 0;
height: 0;
border-bottom: 14px solid transparent;
border-left: 20px solid #7d0b00;
margin-left: 210px;
margin-top: -14px;
}
#Triangle_2 {
position: absolute;
width: 0;
height: 0;
border-bottom: 14px solid transparent;
border-right:20px solid #7d0b00;
margin-top: -14px;
margin-left: -20px;
}
I hope someone could solve this problem that the slider controller keeps overlapping the nav div, which sould be the other way around.
(Let me now if you need some more information)
Well from what i'm seeing, if you want the nav tag to overlap #Slider_Control, since they both have position:absolute, all you have to do is put an higher z-index on your nav tag. Right now your nav is at 1 and your Slider_Control is at 2, so the Slider_Control will always be on top.
But again, I could be wrong, providing the html context of this would help.

Center a popup using CSS

I'm trying to center this popup but I can't seem to get it to work properly on smaller screens like iphone. It looks okay on desktop/laptop screens. Can anyone suggest any ideas how to use media queries to get it the popup to be centered properly regardless of screen size? thanks.
<style type="text/css">
#popup {
display: none;
background: #FFF;
border: 5px solid #444;
padding: 0 15px 15px 15px;
position: fixed;
top: 20%;
left:35%;
width: 25%;
min-width: 210px;
z-index: 100000;
box-shadow: 0 0 10px #000;
border-radius: 5px;
text-align: center;
}
#popup-overlay {
display: none;
background: #000;
opacity: 0.5;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;
}
</style>
The easiest way to do this is to use a transform to centre the element. This will work no matter the width / height of the element
html, body {
height: 100%;
margin: 0;
}
#popup {
/*display: none;*/
background: #FFF;
border: 5px solid #444;
padding: 15px;
position: fixed;
width: 25%;
min-width: 210px;
z-index: 100000;
box-shadow: 0 0 10px #000;
border-radius: 5px;
text-align: center;
top: 50%;
left:50%;
transform: translate(-50%, -50%)
}
#popup-overlay {
/*display: none;*/
background: #000;
opacity: 0.5;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;
}
<div id="popup-overlay"></div>
<div id="popup">Look at me!</div>
Can you try this,
#popup {
display: none;
background: #FFF;
border: 5px solid #444;
padding: 0 15px 15px 15px;
position: fixed;
top: 20%;
left: 50%;
width: 25%;
margin-left: -25%;
min-width: 210px;
z-index: 100000;
box-shadow: 0 0 10px #000;
border-radius: 5px;
text-align: center;
box-sizing: border-box;
}
Note:
It is better to add some jsfiddle like url instead of providing partial details make easy to understand and workout.
left:50%;
margin-left:-120px;
(210 / 2) + 15 = 120
I would move the object to the center and then to the right the half of its size.
As the object width is not fixed, use transform to do that:
#popup {
...
left:50%;
transform: translate(-50%);
...
}
Despite transform is not available in IE8 and below, may be a good solution.
http://jsfiddle.net/fvLtd068/
For html5 enabled browsers use:
#popup {
background: #FFF;
border: 5px solid #444;
padding: 0 15px 15px 15px;
position: fixed;
/* top: 20%; */ //Remove
/* left: 35%; */ //Remove
/* width: 25%; */ //Remove
left: 50%; // Insert
top: 50%; // Insert
transform: translate3d(-50%, -50%, 0); // Insert
min-width: 210px;
z-index: 100000;
box-shadow: 0 0 10px #000;
border-radius: 5px;
text-align: center;
}

Make page fit all screens [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need help with making my HTML fit all screen resolutions. I'd be glad if someone could help, I'll upload root folder. I've tried to make changes but it wont work.
Tried few different resolutions and it works only on 1920x1080 res.
Thanks
.html
{
background-color: #E6E6E6;
}
#page
{
z-index: 1;
width: 1000px;
min-height: 585px;
background-image: none;
border-width: 1px;
border-style: solid;
border-color: #E6E6E6;
background-color: #E6E6E6;
padding-bottom: 61px;
margin-left: auto;
margin-right: auto;
}
#pu27090
{
width: 0.01px;
padding-bottom: 0px;
position: relative;
margin-right: -10000px;
margin-top: 9px;
left: -54px;
}
#u27090
{
z-index: 24;
width: 217px;
margin-left: 52px;
position: relative;
}
#slideshowu5115
{
z-index: 2;
width: 0.01px;
height: 412px;
margin-top: 45px;
position: relative;
}
#u5142
{
position: absolute;
width: 1032px;
height: 412px;
background-color: transparent;
left: 38px;
}
#u5142popup
{
z-index: 3;
}
#u5143
{
z-index: 4;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5190
{
z-index: 6;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u13904
{
z-index: 8;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5208
{
z-index: 10;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5217
{
z-index: 12;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5226
{
z-index: 14;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5235
{
z-index: 16;
width: 1032px;
height: 412px;
border-style: none;
border-color: transparent;
background-color: #4F4F4F;
margin-right: -10000px;
position: relative;
}
#u5143_clip,#u5190_clip,#u13904_clip,#u5208_clip,#u5217_clip,#u5226_clip,#u5235_clip
{
overflow: hidden;
width: 1032px;
height: 412px;
}
#u5143_img,#u5190_img,#u13904_img,#u5208_img,#u5217_img,#u5226_img,#u5235_img
{
margin-left: -3px;
margin-right: -3px;
}
#u5139-3
{
position: absolute;
width: 15px;
min-height: 20px;
border-style: none;
border-color: transparent;
padding: 10px;
line-height: 20px;
text-align: center;
color: #999999;
font-family: Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
top: 173px;
background: transparent url("../images/levo.png") no-repeat left top;
}
#u5139-3popup
{
z-index: 18;
}
#u5135-3
{
position: absolute;
width: 15px;
min-height: 20px;
border-style: none;
border-color: transparent;
padding: 10px;
line-height: 20px;
text-align: center;
color: #999999;
font-family: Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
top: 173px;
left: 1073px;
background: transparent url("../images/desno.png") no-repeat left top;
}
#u5135-3popup
{
z-index: 21;
}
.SSSlideLoading /* slideshowFreeStyle */
{
background: url("../images/loading.gif") no-repeat center center;
}
#menuu27092
{
z-index: 26;
width: 585px;
position: relative;
margin-right: -10000px;
margin-top: 62px;
left: 230px;
}
#u27093
{
width: 130px;
min-height: 31px;
position: relative;
margin-right: -10000px;
}
#u27096
{
width: 130px;
border-style: none;
border-color: transparent;
background-color: transparent;
padding-bottom: 13px;
position: relative;
}
#u27096.MuseMenuActive
{
border-style: none;
border-color: transparent;
margin: 0px;
background: transparent url("../images/kvacicaa.png") no-repeat left top;
}
#u27098-4
{
position: relative;
margin-right: -10000px;
top: 6px;
left: 44px;
}
#u27098-4_clip
{
overflow: hidden;
width: 42px;
height: 17px;
vertical-align: top;
}
#u27098-4_img
{
display: block;
}
#u27127
{
width: 161px;
min-height: 31px;
position: relative;
margin-right: -10000px;
left: 132px;
}
#u27128
{
width: 161px;
border-style: none;
border-color: transparent;
background-color: transparent;
padding-bottom: 13px;
position: relative;
}
#u27128:hover
{
margin: 0px;
background: transparent url("../images/kvacicaa.png") no-repeat left top;
}
#u27130
{
height: 17px;
width: 73px;
vertical-align: top;
background: url("../images/u27130.png") no-repeat 0px 0px;
position: relative;
margin-right: -10000px;
top: 6px;
left: 44px;
}
#u27128.MuseMenuActive #u27130
{
background: url("../images/u27130-a.png") no-repeat 0px 0px;
}
#u27120
{
width: 135px;
min-height: 31px;
position: relative;
margin-right: -10000px;
left: 295px;
}
#u27123
{
width: 135px;
border-style: none;
border-color: transparent;
background-color: transparent;
padding-bottom: 13px;
position: relative;
}
#u27128:active,#u27123:hover
{
margin: 0px;
background: transparent url("../images/kvacicaa.png") no-repeat left top;
}
#u27124
{
height: 17px;
width: 48px;
vertical-align: top;
background: url("../images/u27124.png") no-repeat 0px 0px;
position: relative;
margin-right: -10000px;
top: 6px;
left: 43px;
}
#u27123.MuseMenuActive #u27124
{
background: url("../images/u27124-a.png") no-repeat 0px 0px;
}
#u27113
{
width: 153px;
min-height: 31px;
position: relative;
margin-right: -10000px;
left: 432px;
}
#u27116
{
width: 153px;
border-style: none;
border-color: transparent;
background-color: transparent;
padding-bottom: 13px;
position: relative;
}
#u27123:active,#u27116:hover
{
margin: 0px;
background: transparent url("../images/kvacicaa.png") no-repeat left top;
}
#u27116:active
{
margin: 0px;
background: transparent url("../images/kvacicaa.png") no-repeat left top;
}
#u27117
{
height: 17px;
width: 65px;
vertical-align: top;
background: url("../images/u27117.png") no-repeat 0px 0px;
position: relative;
margin-right: -10000px;
top: 6px;
left: 44px;
}
#u27116.MuseMenuActive #u27117
{
background: url("../images/u27117-a.png") no-repeat 0px 0px;
}
.SSFirstButton,.SSPreviousButton,.SSNextButton,.SSLastButton,.SSSlideLink,.SSCloseButton,.MenuItem /* slideshowFreeStyle */
{
cursor: pointer;
}
body
{
padding-top: 35px;
}
#page .verticalspacer
{
clear: both;
}
if you are trying to make it fit in all the screen sizes. always use media queries.
Something like this will easy for you. its clean and simple
/* Tablet Landscape */
#media screen and (max-width: 1060px) {
#primary { width:67%; }
#secondary { width:30%; margin-left:3%;}
}
/* Tabled Portrait */
#media screen and (max-width: 768px) {
#primary { width:100%; }
#secondary { width:100%; margin:0; border:none; }
}
The easiest way to make your page fit all screens would be to use media queries which set specific rules depending on the width of the screen. Media queries are the magic behind responsive website design. I would suggest ready more about media queries and also you can use the query template below.
// Small screens
#media only screen { } /* Define mobile styles */
#media only screen and (max-width: 40em) { } /* max-width 640px, mobile-only styles, use when QAing mobile issues */
// Medium screens
#media only screen and (min-width: 40.063em) { } /* min-width 641px, medium screens */
#media only screen and (min-width: 40.063em) and (max-width: 64em) { } /* min-width 641px and max-width 1024px, use when QAing tablet-only issues */
// Large screens
#media only screen and (min-width: 64.063em) { } /* min-width 1025px, large screens */
#media only screen and (min-width: 64.063em) and (max-width: 90em) { } /* min-width 1025px and max-width 1440px, use when QAing large screen-only issues */
// XLarge screens
#media only screen and (min-width: 90.063em) { } /* min-width 1441px, xlarge screens */
#media only screen and (min-width: 90.063em) and (max-width: 120em) { } /* min-width 1441px and max-width 1920px, use when QAing xlarge screen-only issues */
// XXLarge screens
#media only screen and (min-width: 120.063em) { } /* min-width 1921px, xlarge screens */