I had an iframe element inside a div working just fine. I wanted to resize the iframe video but I couldn't centre it, so I added another div to contain both the div and the iframe. And after doing this, you couldn't click the video anymore.
Here's the chunk of code regarding this problem. As you will see, I already tried setting z-index values and pointer-events: none;.
#botNavBar {
height: auto;
padding-top: 50px;
padding-bottom: 100px;
padding-left: 150px;
padding-right: 150px;
position: relative;
background: black;
display: flex;
flex-direction: column;
z-index: -1;
align-items: center;
}
#videoResizer {
width: 60%;
z-index: 2;
pointer-events: none;
}
#videoContainer {
width: 100%;
position: relative;
padding-bottom: 56.25%;
align-items: center;
justify-content: center;
text-align: center;
z-index: 2;
pointer-events: none;
}
#trailerTwogether {
position: absolute;
display: block;
width: 100%;
height: 100%;
border-style: none;
z-index: 200000000000000;
}
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
#contactInfo {
Font-Family: 'Raleway', Sans-Serif;
Font-Size: 16px;
color: rgb(214, 234, 248);
margin-bottom: 0px;
padding-top: 50px;
}
#contactMail {
Font-Family: 'Raleway', Sans-Serif;
Font-Size: 16px;
color: darkmagenta;
margin-bottom: 0px;
padding-top: 0px;
margin-top: 0px;
}
<div id="botNavBar">
<div id="videoResizer">
<div id="videoContainer">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br>
Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
https://jsfiddle.net/Als3rr/e7kqv4wd/
I removed the styles by adding 1 in id in all 3 divs of iframe.
I have added inline style for iframe
I have added "padding-top:100px;" for #leftSide
It worked fine [https://i.stack.imgur.com/O9BUt.png][1]
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
padding-top:100px;
}
<div id="botNavBar1">
<div id="videoResizer1">
<div id="videoContainer1">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E" style="height:20%; width:20%"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br>
Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
The main issue is that you have a z-index: -1; on the top level element (#botNavBar). This puts this div "behind" the body.
Also the pointer-events: none; you have added in an attempt to solve the issue are unfortunately causing it in another way, so those also need to be removed.
Other small issues:
Font-Family and Font-Size should be all lower-case
This snippet won't display the issue here as the iframe is blocked inside a StackOverflow snippet, but it will work in a real enviroment.
#botNavBar {
height: auto;
padding-top: 50px;
padding-bottom: 100px;
padding-left: 150px;
padding-right: 150px;
position: relative;
background: black;
display: flex;
flex-direction: column;
align-items: center;
}
#videoResizer {
width: 60%;
z-index: 2;
}
#videoContainer {
width: 100%;
position: relative;
padding-bottom: 56.25%;
align-items: center;
justify-content: center;
text-align: center;
z-index: 2;
}
#trailerTwogether {
position: absolute;
display: block;
width: 100%;
height: 100%;
border-style: none;
z-index: 200000000000000;
}
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
#contactInfo {
font-family: 'Raleway', Sans-Serif;
font-size: 16px;
color: rgb(214, 234, 248);
margin-bottom: 0px;
padding-top: 50px;
}
#contactMail {
font-family: 'Raleway', Sans-Serif;
font-size: 16px;
color: darkmagenta;
margin-bottom: 0px;
padding-top: 0px;
margin-top: 0px;
}
<div id="botNavBar">
<div id="videoResizer">
<div id="videoContainer">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br> Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
Related
I have a style that I'm trying to implement into my web page.
.dp-htkhbrvt {
align-items: flex-start;
background-color: #fafffc;
border: 0.07vw none;
display: flex;
height: 71.11vw;
padding: 0 0.01vw;
width: 100.0vw;
}
.dp-htkhbrvt .text-7 {
color: var(--black);
margin-left: 4.38vw;
margin-top: 68.89vw;
min-height: 1.11vw;
min-width: 3.4vw;
}
.dp-htkhbrvt .text-6 {
color: var(--black);
margin-left: 1.39vw;
margin-top: 68.89vw;
min-height: 1.11vw;
min-width: 2.36vw;
}
.dp-htkhbrvt .flex-col {
align-items: flex-start;
display: flex;
flex-direction: column;
gap: 3.4vw;
margin-left: 23.68vw;
margin-top: 13.26vw;
min-height: 57.85vw;
width: 64.79vw;
}
.dp-htkhbrvt .logo-option-2 {
height: 5.35vw;
margin-left: 7.36vw;
width: 14.86vw;
}
.dp-htkhbrvt .overlap-group {
height: 49.1vw;
position: relative;
width: 64.79vw;
}
.dp-htkhbrvt .log-in-card {
align-items: center;
background-color: #ffffff;
border-radius: 0.35vw;
box-shadow: 0.0vw 0.62vw 3.19vw #0000001a;
display: flex;
flex-direction: column;
gap: 1.39vw;
height: 27.08vw;
left: 0;
padding: 2.78vw 2.08vw;
position: absolute;
top: 0;
width: fit-content;
}
.dp-htkhbrvt .text-1 {
color: var(--black);
margin-top: -0.07vw;
width: fit-content;
}
.dp-htkhbrvt .type-bar-icon-right {
gap: 16.53vw;
height: 3.26vw;
padding: 0.9vw 0.69vw 0.9vw 0.0vw;
}
.dp-htkhbrvt .group-8 {
align-self: stretch;
height: 1.46vw;
margin-right: -0.14vw;
min-width: 6.67vw;
position: relative;
}
.dp-htkhbrvt .text_label {
color: var(--black);
direction: rtl;
font-weight: 400;
left: 0;
line-height: normal;
opacity: 0.5;
position: absolute;
top: 0;
}
.dp-htkhbrvt .type-bar-icon-left {
padding: 0.9vw 0.69vw;
}
.dp-htkhbrvt .icon-eye {
height: 1.67vw;
min-width: 1.67vw;
}
.dp-htkhbrvt .text-2 {
align-self: stretch;
color: #000000cc;
flex: 1;
margin-top: -0.05vw;
opacity: 0.5;
}
.dp-htkhbrvt .text-3 {
align-self: stretch;
color: var(--black);
flex: 1;
font-family: var(--font-family-arimo);
font-size: var(--font-size-m);
letter-spacing: 0;
text-decoration: underline;
}
.dp-htkhbrvt .primary-action-btn {
background-color: var(--main);
border-radius: 0.35vw;
height: 3.47vw;
min-width: 25.35vw;
position: relative;
}
.dp-htkhbrvt .text-4 {
color: var(--black);
left: 10.07vw;
position: absolute;
top: 0.9vw;
}
.dp-htkhbrvt .text-5 {
color: var(--black);
text-align: center;
width: fit-content;
}
.dp-htkhbrvt .illustration-1 {
height: 24.31vw;
left: 24.38vw;
position: absolute;
top: 24.79vw;
width: 40.42vw;
}
.dp-htkhbrvt .text {
direction: rtl;
font-weight: 400;
line-height: normal;
}
.dp-htkhbrvt .type-bar-icon {
align-items: center;
border: 0.05vw solid;
border-color: var(--black);
border-radius: 0.35vw;
display: flex;
justify-content: flex-end;
width: 25.35vw;
}
<input type="hidden" id="anPageName" name="page" value="dp-htkhbrvt" />
<div class="container-center-horizontal">
<div class="dp-htkhbrvt text-14px screen">
<div class="text-7 text">צור קשר</div>
<div class="text-6 text">אודות</div>
<div class="flex-col">
<img class="logo-option-2" src="{% static 'images/img/logo.svg' %}" alt="logo option 2" />
<div class="overlap-group">
<div class="log-in-card">
<h2 class="text-1 text h2">כניסה למערכת</h2>
<div class="type-bar-icon-right type-bar-icon">
<div class="group-8">
<div class="text_label text">שם משתמש</div>
</div>
</div>
<div class="type-bar-icon-left type-bar-icon">
<img class="icon-eye" src="{% static 'images/img/eye.svg' %}" alt="icon-eye" />
<div class="text-2 text text">סיסמה</div>
</div>
<!-- <div class="text-3 text">שכחתי סיסמה</div> -->
<div class="primary-action-btn">
<div class="text-4 text text">התחברות</div>
</div>
<p class="text-5 text text-14px">עוד לא הצטרפתם אלינו? לחצו כאן</p>
</div>
<img class="illustration-1" src="{% static 'images/img/illu.svg' %}" alt="illustration 1" />
</div>
</div>
</div>
</div>
Could someone please help me make the entire thing fit my screen? What happens now is that the screen has a scrollbar, and you have to scroll to see some of the elements. I want everything to fit in my screen, or any resolution for that matter. In other words, I want the entire thing to "shrink" and fit in any given desktop resolution (not even mobile, just desktop)
Would very much appreciate any help!
Thank you!
I wan't to add a p like this.
I can add it, but when I use margin-top to put it down, it affects the elements above like this.
I don't know how to solve this.
Thank you.
HTML.
<main>
<section class="home">
<div class="presentation">
<p class="hello">HELLO THERE</p>
<p>I'm Lautaro Rojas</p>
<p>Web developer</p>
<p class="scroll">SCROLL DOWN</p>
</div>
<div class="presentation-buttons">
<button>LATEST PROJECTS</button>
<button>MORE ABOUT ME</button>
</div>
</section>
</main>
CSS:
main {
width: 100%;
height: 100%;
.home {
width: 100%;
height: 100%;
background-image: url("../img/bg.jpg");
background-size: cover;
display: flex;
align-items: center;
.presentation {
width: 70%;
height: 100%;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
gap: 5px;
p {
width: 50%;
margin: 0;
text-align: left;
color: $WHITE;
font-family: Merriweather-Regular;
font-size: 70px;
letter-spacing: 2px;
}
p[class="hello"] {
font-size: 30px;
color: $PINK;
}
p[class="scroll"] {
margin-top:180px;
font-size: 10px;
}
}
}
}
position: absolute; is your friend...
<main>
<section class="home">
<div class="presentation">
<p class="hello">HELLO THERE</p>
<p>I'm Lautaro Rojas</p>
<p>Web developer</p>
<p class="scroll">SCROLL DOWN</p>
</div>
<div class="presentation-buttons">
<button>LATEST PROJECTS</button>
<button>MORE ABOUT ME</button>
</div>
</section>
</main>
main {
width: 100%;
height: 100%;
.home {
width: 100%;
height: 100%;
background-image: url("../img/bg.jpg");
background-size: cover;
display: flex;
align-items: center;
.presentation {
width: 70%;
height: 100%;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
gap: 5px;
position: relative;
p {
width: 50%;
margin: 0;
text-align: left;
color: $WHITE;
font-family: Merriweather-Regular;
font-size: 70px;
letter-spacing: 2px;
}
p[class="hello"] {
font-size: 30px;
color: $PINK;
}
p[class="scroll"] {
margin-top:180px;
font-size: 10px;
position: absolute;
}
}
}
}
I have met some problems while doing a image-viewer project. The problem is that my buttons and the image are not following justify-content property, which they don't distributed equally inside my div block, how could it be solved? Also the image is not centered as the title does despite I set the align item property. I dow know how to fix that. I've searched over the website for solutions but none of them seems working.
Could anyone help me, please? Thanks in advance.
Here are the html and css code:
<div class="image-viewer__container">
<div class="image-viewer__title">Image Viewer</div>
<div class="image-viewer__main">
<div class="image-viewer__button"><img src="./images/back.png" id="previous" /></div>
<div class="image-viewer__display" style="background-image: url(./images/loading.gif);background-repeat: no-repeat; background-position: center;">
<img src="https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF" id="display">
<div class="image-viewer__display-source-wrapper">
<span><a href="https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF" target="_blank">
https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF</a>
</span>
</div>
</div>
<div class="image-viewer__button"><img src="./images/next.png" id="next" /></div>
</div>
</div>
.image-viewer__container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
}
.image-viewer__title {
font-size: 5rem;
font-weight: 600;
color: #615dec;
margin: 0;
margin-top: 2rem;
}
.image-viewer__main {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin: auto;
}
.image-viewer__button {
display: inline;
background: none;
border: none;
border-radius: 50%;
}
.image-viewer__button img {
width: 80px;
height: 80px;
border: 1px solid transparent;
border-radius: 50%;
cursor: pointer;
}
.image-viewer__display {
position: relative;
padding: 15px;
margin: 3rem;
max-width: 80rem;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
font-size: 0.6rem;
}
.image-viewer__display-source-wrapper {
position: absolute;
font-size: 12px;
left: 50%;
margin-right: 50%;
transform: translate(-50%, -50%);
min-width: 100em;
text-align: center;
bottom: 0;
}
#display {
object-fit: contain;
width: 50rem;
height: 30rem;
margin-bottom: 1rem;
}
#source {
display: inline;
color: black;
}
This is because you've set a fixed width to your image. By setting the main image to 100% the image will fit and fill up the remaining space so the 3 elements are always distributed equally.
main image size = full width - both your arrows
current
#display {
object-fit: contain;
width: 50rem; /*fixed width*/
height: 30rem; /*fixed width*/
margin-bottom: 1rem;
}
amended
#display {
margin-bottom: 1rem;
width: 100%; /*was added*/
height: auto; /*was added*/
}
jsFiddle
Add css float:"right" in css button.
Hope someone can shed light on this question of mine.
I have a flex container, which has 2 flex containers with flex-direction: column.
However, it all displays in 1 column.
Initially, it displayed in 2 columns but did not start at the same height, and now it is in one column only.
Advise here will be appreciated.
<!-- ***** finding container ***** -->
section.finding-container {
top: 180px;
display: flex;
flex-direction: row;
position: absolute;
justify-content: space-between;
align-items: center;
/* height: 100% */
/* margin-right: 215px; */
}
.find-agent {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 350px;
margin-bottom: auto;
margin-left: 50px;
}
.find-agent img,
h1,
p,
button {
display: block;
margin-left: auto;
margin-right: auto;
}
.find-agent h1 {
font-weight: 550;
color: #1E95EE;
text-align: center;
margin-top: 12px;
margin-bottom: 0;
}
.find-agent p {
color: #3A3C3E;
font-weight: 350;
width: 445px;
height: 71px;
text-align: center;
opacity: 1;
}
.try {
border: 2px solid #1E95EE;
border-radius: 5px;
opacity: 1;
color: #1E95EE;
font-size: 18px;
font-weight: Regular;
height: 50px;
width: 143px;
text-align: center;
vertical-align: middle;
text-decoration: none;
justify-content: center;
}
.agent-profiles {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 0;
margin-bottom: auto;
}
.agent-profiles h2,
img {
display: block;
margin-left: auto;
margin-right: auto;
}
.agent-profiles h2 {
font-weight: 350;
color: #1E95EE;
text-align: center;
width: 182px;
height: 44px;
letter-spacing: 0;
opacity: 1;
}
```
<!-- ***** finding container ***** -->
<section class="finding-container">
<div class="find-agent">
<img src="./images/search.svg" alt="search">
<h1>Find the perfect agent</h1>
<p>
No more browsing through thousands of applications. Each week, we'll send you a fresh batch of hand-picked, personally-vetted candidates.
</p>
<button type="button" class="try">Try today</button>
</div>
<div class="agent-profiles">
<h2>
Selections from the Overpass Marketplace
</h2>
<img src="./images/profiles.svg" alt="profiles">
</div>
</section>
I have a flex container, which has 2 flex containers with flex-direction: column.
You've got an invalid comment in your CSS, which is breaking your first line of code:
<!-- ***** finding container ***** -->
section.finding-container {
top: 180px;
display: flex;
flex-direction: row;
position: absolute;
justify-content:space-between;
align-items: center;
/* height: 100% */
/* margin-right: 215px; */
}
That's HTML commenting syntax. In CSS, it's invalid, so the following section.finding-container selector is seen as an error and ignored. The container then falls back to its default layout model, display: block, which stacks child elements vertically. (You can see the proper CSS commenting syntax at the bottom of your rule.)
More details about CSS commenting syntax and error handling:
Why are some of my CSS rules not working?
Initially, it displayed in 2 columns but did not start at the same height ...
You've got all sorts of margins and alignment properties (such as justify-content) set on the items and container, so they're rendering at different heights.
section.finding-container {
/* top: 180px; */
display: flex;
flex-direction: row;
position: absolute;
justify-content: space-between;
/* align-items: center; */
border: 2px dashed red; /* for illustration purposes */
padding: 10px; /* for illustration purposes */
}
.find-agent {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
/* margin-top: 350px; */
/* margin-bottom: auto; */
/* margin-left: 50px; */
border: 1px solid green; /* for illustration purposes */
}
.find-agent img,
h1,
p,
button {
display: block;
margin-left: auto;
margin-right: auto;
}
.find-agent h1 {
font-weight: 550;
color: #1E95EE;
text-align: center;
margin-top: 12px;
margin-bottom: 0;
}
.find-agent p {
color: #3A3C3E;
font-weight: 350;
width: 445px;
height: 71px;
text-align: center;
opacity: 1;
}
.try {
border: 2px solid #1E95EE;
border-radius: 5px;
opacity: 1;
color: #1E95EE;
font-size: 18px;
font-weight: Regular;
height: 50px;
width: 143px;
text-align: center;
vertical-align: middle;
text-decoration: none;
justify-content: center;
}
.agent-profiles {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 0;
/* margin-bottom: auto; */
border: 1px solid black; /* for illustration purposes */
}
.agent-profiles h2,
img {
display: block;
margin-left: auto;
margin-right: auto;
}
.agent-profiles h2 {
font-weight: 350;
color: #1E95EE;
text-align: center;
width: 182px;
height: 44px;
letter-spacing: 0;
opacity: 1;
}
<section class="finding-container">
<div class="find-agent">
<img src="./images/search.svg" alt="search">
<h1>Find the perfect agent</h1>
<p>
No more browsing through thousands of applications.
Each week, we'll send you a fresh batch of hand-picked,
personally-vetted candidates.
</p>
<button type="button" class="try">Try today</button>
</div>
<div class="agent-profiles">
<h2>
Selections from the
Overpass Marketplace
</h2>
<img src="./images/profiles.svg" alt="profiles">
</div>
</section>
I'm trying to align the text within my h2 element. I would like it to be centered vertically within the div. I'm working in .NET MVC
My html: (this is the only part giving me trouble)
Specifically:
.banner-side-container {
height: 240px;
width: 180px;
vertical-align: middle;
}
.banner-side-container h2 {
margin: 0;
padding: 0;
text-align: center;
}
.view-teams-banner {
margin-top: 10px;
height: 110px;
width: 180px;
background-color: aqua;
border-radius: 20px;
}
.view-matches-banner {
margin-top: 10px;
height: 110px;
width: 180px;
background-color: darkorchid;
border-radius: 20px;
}
<td>
<div class="banner-side-container">
<div class="view-teams-banner">
<h2>View Teams</h2>
</div>
<div class="view-matches-banner">
<h2>View Matches</h2>
</div>
</div>
</td>
I've tried adding vertical-align: middle; to all 4 selectors with no success.
Further info: the text-align: center; worked perfectly.
You can use flex and add the following settings to the three elements wrapping the h2s and their parent elements as follows:
display: flex;
flex-direction: column;
justify-content: center;
.banner-side-container {
height: 240px;
width: 180px;
display: flex;
flex-direction: column;
justify-content: center;
}
.banner-side-container h2 {
margin: 0;
padding: 0;
text-align: center;
}
.view-teams-banner {
margin-top: 10px;
height: 110px;
width: 180px;
background-color: aqua;
border-radius: 20px;
display: flex;
flex-direction: column;
justify-content: center;
}
.view-matches-banner {
margin-top: 10px;
height: 110px;
width: 180px;
background-color: darkorchid;
border-radius: 20px;
display: flex;
flex-direction: column;
justify-content: center;
}
<td>
<div class="banner-side-container">
<div class="view-teams-banner">
<h2>View Teams</h2>
</div>
<div class="view-matches-banner">
<h2>View Matches</h2>
</div>
</div>
</td>