What can I improve to make a responsive design - html

When resizing the <p > tag breaks out of its parent <div>, how can I
make it responsive and stay in the <div> HTML code. That's what I
want to achieved with HTML and CSS: I tried to wrap everything in a div so I can control elements using absolute elements so I can center it in the middle.
Thank you in advance for your advices to help me make nicely written websites in the future.
#import url('https://fonts.googleapis.com/css?family=Didact+Gothic');
html,body {
height: 100%;
}
body {
margin: 0;
background-color: #eee;
}
header {
height: 100vh;
background-size: cover;
position: relative;
height: 100%;
background-image: url("/images/background.jpeg")
}
.text {
position: relative;
width: 100%;
height: 100%;
}
.text1 {
font-size: 35vh;
position:absolute;
top: 5%;
left: 5%;
color: #fff;
font-weight: bold;
margin: 0;
height: auto;
}
.text2 {
margin: 0;
font-size: 35vh;
position:absolute;
left:33%;
top: 40%;
font-size: 5vh;
text-transform: uppercase;
}
.text3 {
position:absolute;
left: 15%;
top: 50%;
width: 50vh;
height: auto;
margin: 0;
font-weight: 4vh;
font-weight: bold;
font-style: italic;
font-family: 'Didact Gothic', sans-serif;
color: #fff;
}
.text4 {
position:absolute;
left: 15%;
top: 65%;
margin: 0;
width: 50vh;
font-weight: bold;
font-style: italic;
color: #fff;
font-family: 'Didact Gothic', sans-serif;
}
<header id="showcase">
<div class="text">
<h1 class="text1">-20%</h1>
<h1 class="text2">Rabbat</h1>
<p class="text3">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel facilisis volutpat est velit egestas dui.
</p>
<p class="text4">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel facilisis volutpat est velit egestas dui.
</p>
</div>
</header>

Use this in your head tag, and try not to use absolute positions for inner controls
<style>
p{
work-break: break-all;
}
</style>

Related

Image Shifting when Webpage is Resized after Floating Left

I have no idea why my image is shifting when my webpage is resized. There is no absolute positioning, the image just floats left, and the parents only give it some padding and margin.
Here is the HTML:
.section-title {
color: black;
font-size: 30px;
font-weight: bold;
text-align: center;
}
.section-title-info {
margin-bottom: 1.5em;
margin-top: 0;
}
.section-words-info {
font-size: 20px;
color: black;
font-weight: 550;
line-height: 30px;
}
.section-info {
background-color: #706D9F;
padding: 2em 1em;
}
.container {
margin: 0 auto;
}
.img-main {
float: left;
height: 12em;
border-radius: 50%;
}
<section class="section-info container">
<h2 class="section-title section-title-info">Information</h2>
<img class="img-main" src="https://ibb.co/g7LnzSc">
<span class="section-words-info">Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</section>
You need to add overflow: auto; to your .section-info By using float it takes that element out of the flow of the document so you need to force the parent to include it by using overflow auto. See here:
.section-title {
color: black;
font-size: 30px;
font-weight: bold;
text-align: center;
}
.section-title-info {
margin-bottom: 1.5em;
margin-top: 0;
}
.section-words-info {
font-size: 20px;
color: black;
font-weight: 550;
line-height: 30px;
}
.section-info {
background-color: #706D9F;
padding: 2em 1em;
overflow: auto;
}
.container {
margin: 0 auto;
}
.img-main {
float: left;
height: 12em;
border-radius: 50%;
}
<section class="section-info container">
<h2 class="section-title section-title-info">Information</h2>
<img class="img-main" src="https://w3schools.com/html/img_girl.jpg" />
<span class="section-words-info">Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</section>

Lay <HR> on top of a box in CSS

I have a specific box style that I'm trying to accomplish and it's got me stumped. Here is a reference image:
box with border and additional line styling
A few items, first and foremost, I'm beginning to learn responsive design and I've been able to accomplish this but as soon as I start to resize it breaks. I would like it the box and hr to work all as one item.
What I've tried:
- Box with border
- HR styled within the box div and outside
- HR with Z-Index
Here is the code:
#valuesContainer {
border: 1px;
border-style: solid;
border-color: #ccc;
font-family: sans-serif;
font: Source;
font-weight: normal;
font-size: 20px;
margin: 8%;
padding: 5%;
line-height: 1;
}
#valueTitle {
font-family: sans-serif;
font: Source;
font-weight: 600;
font-size: 22px;
}
#hrTop {
width: 30vh;
color: red;
border-top: 5px solid #E7503D;
position: relative;
margin-right: -.2%;
margin-top: -.75%;
z-index: 999;
}
#hrTopRight {
border: none;
border-left: 5px solid #E7503D;
height: 10vw;
width: 1px;
margin-top: -16%;
}
<div class="row">
<div class="col-6">
<div id="valuesContainer" class="box">
<hr id="hrTop"align="right">
<h1 id="valueTitle">Title</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat scelerisque varius morbi enim nunc.
</p>
<hr id="hrTopRight"align="right">
</div>
</div>
I'm not entirely sure I'm going about this the right way, but any help would greatly appreciate it. I have tried to search around and this is as far as I've been able to get with the information I found.'
UPDATE:
I couldn't see a way to award this answer since it was a comment. But I believe I may have found a much better way of doing this without using an HR tag.
t looks like you are using to decorate the box and not to indicate a separation in your content (since they are at the very start and end). You can use a pseudo-element on your #valuesContainer instead to layer a box on top with absolute positioning (make sure #valuesContainer is relatively positioned).
Try using position: absolute and relative on the parent div
#valuesContainer {
border: 1px;
border-style: solid;
border-color: #ccc;
font-family: sans-serif;
font: Source;
font-weight: normal;
font-size: 20px;
margin: 8%;
padding: 5%;
line-height: 1;
position: relative;
}
#valueTitle {
font-family: sans-serif;
font: Source;
font-weight: 600;
font-size: 22px;
}
#hrTop {
width: 30vh;
color: red;
border-top: 5px solid #E7503D;
position: absolute;
top: -17px;
right: -7px;
z-index: -999999;
}
#hrTopRight {
border: none;
border-left: 5px solid #E7503D;
height: 10vw;
width: 1px;
position: absolute;
top: -14px;
right: -8px;
}
<div class="row">
<div class="col-6">
<div id="valuesContainer" class="box">
<hr id="hrTop"align="right">
<h1 id="valueTitle">Title</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat scelerisque varius morbi enim nunc.
</p>
<hr id="hrTopRight"align="right">
</div>
</div>

why is the text not moving up?

Why is the text p not moving up ?
I have tried to move it with: bottom, margin-bottom, padding-bottom. It moves only when I remove the bluePoint1 div.
.bluePoint1 {
left: -12px;
margin-right: 10px;
font-size: 3.75rem;
color: #5CABD1;
}
p {
font-family: Roboto, sans-serif;
font-size: 16px;
font-weight: normal;
text-align: center;
bottom: 1000px;
}
<div class="bluePoint1">&bull</div>
<p>Lorem Ipsum dolor sit amet, consecteur adipiscing elit, sed do elusmod tempor incididumt ut <br> et dolore magna aliqua. Ut enim ad minim veniam</p>
Hi add the following in you p tag in css:
margin-top: -20px;
The entire css will look like this:
.bluePoint1 {
left: -12px;
margin-right: 10px;
font-size: 3.75rem;
color: #5CABD1;
}
p {
font-family: Roboto, sans-serif;
font-size: 16px;
font-weight: normal;
text-align: center;
bottom: 1000px;
margin-top: -20px;
}
add margin:0 to your p element
JsFiddle

How can I make my CSS text captions fade in and fade out?

I have been trying to make an image map with HTML and CSS where the user rolls over a certain part of an image and a text caption pops up. I think i am nearly there but i would like the text caption to fade in and fade out instead of just appearing and disappearing. Could any one point me in the right direction please? Here is the code i have so far:
#map {
margin: 0;
padding: 0;
width: 400px;
height: 250px;
background: #000;
font-family: 'Lato', Calibri, Arial, sans-serif;
font-size: 10pt;
font-weight: 700;
line-height: 18px;
}
#map h1 {
margin: 0px;
padding-bottom: 5px;
color: #fff;
font-size: 12pt;
font-weight: 700;
}
#map li {
margin: 0;
padding: 0;
list-style: none;
}
#map li a {
position: absolute;
display: block;
background: url(images/blank.gif);
text-decoration: none;
color: #ed4e6e;
}
#map li a span {
display: none;
}
#map li a:hover span {
position: relative;
display: block;
width: 200px;
left: 20px;
top: 20px;
border: 0px solid #000;
border-radius: 5px;
background: #2c3f52;
padding: 20px;
}
#map a.caption1 {
top: 80px; left: 60px;
width: 10px;
height: 10px;
background: #ff0035;
}
#map a.caption2 {
top: 80px;
left: 190px;
width: 10px;
height: 10px;
background: #ff0035;
}
#map a.caption3 {
top: 180px;
left: 60px;
width: 10px;
height: 10px;
background: #ff0035;
}
#map a.caption4 {
top: 170px;
left: 250px;
width: 10px;
height: 10px;
background: #ff0035;
}
#map a.caption5 {
top: 90px;
left: 365px;
width: 10px;
height: 10px;
background: #ff0035;
}
<ul id="map">
<li><a class="caption1" href="#" title=""><span>
<h1>Caption 1</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span></a></li>
<li><a class="caption2" href="#" title=""><span>
<h1>Caption 2</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span></a></li>
<li><a class="caption3" href="#" title=""><span>
<h1>Caption 3</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span></a></li>
<li><a class="caption4" href="#" title=""><span>
<h1>Caption 4</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span></a></li>
<li><a class="caption5" href="#" title=""><span>
<h1>Caption 5</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span></a></li>
</ul>
You can change your current css into this
#map li a span {
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
#map li a:hover span {
position: relative;
width: 200px;
display: block;
z-index: 10;
visibility: visible;
opacity: 1;
left: 20px;
top: 20px;
border: 0px solid #000;
border-radius: 5px;
background: #2c3f52;
padding: 20px;
}
Fiddle: http://codepen.io/hunzaboy/pen/mOWOqa

Equally Marginalize a Left-Aligned Size-Changing Box w/ Image Container in CSS/SASS

Here's the challenge. I have a left-aligned text container (width: 40%;) that changes height with the window. I need my right half of the screen set as an image container (width: 60%) to which the image centers horizontally in the container, and vertically with the center of the text container.
Here is what my current code is doing:
Here is what I would like it to do:
I'm barely savvy in JS, so I'm trying to avoid it pending the need for tweaks. Here is my current code for the section:
.design-portfolio {
position: relative;
.web-img-container {
position: relative;
width: 60%;
margin-left: auto;
.web-img-lg {
img {
max-height: 40em;
}
}
}
.web-img-sm {
#media (min-width:75.063em) {
position: absolute;
visibility: hidden;
}
}
.web-design-box {
#media (min-width:75.063em) {
$font-title: 25px NexaBook;
$font-sub-title: 25px NexaHeavy;
$font-copy-title: 20px NexaHeavy;
$font-copy: 20px NexaBook;
position: relative;
width: 40%;
padding-right: 2em;
.size-fix {
position: relative;
}
.bg-box {
position: absolute;
background-color: $pink;
top: 2em;
bottom: 2em;
left: 0;
right: -2em;
}
.border-box {
position: relative;
border: .3em solid $black;
padding-left: 2em;
padding-right: 2em;
padding-bottom: 2em;
padding-top: 3em;
width: 60%;
margin-left: auto;
.h1 {
font: $font-title;
color: $white;
text-align: right;
}
.h2 {
font: $font-sub-title;
text-align: right;
}
.copy {
font: $font-copy;
color: $white;
text-align: left;
width: 100%;
height: 100%;
.h3 {
font: $font-copy-title;
color: $white;
text-align: left;
}
}
.copy p {
line-height: 1.2;
}
}
}
}
}
<section>
<div class="web-img-container">
<div class="web-img-lg">
<img src="assets/img/website-design.png" alt="web-design">
</div>
</div>
<div class="web-design-box">
<div class="size-fix">
<div class="bg-box"></div>
<div class="border-box">
<div class="h1">
my approach on
</div>
<div class="h2">
website design
</div>
<br>
<div class="copy">
<div class="h3">purpose</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<div class="h3">simplicity</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<div class="h3">mobile first</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</div>
</div>
</section>
I don't know how to set it up to run, as it's in SASS rather than regular CSS. :/