Text moving to next line without width issues - html

I am completely stumped on an issue I am having. It is the simplest issue, but I just can't locate the issue. I have a line of text with a border around it to act as a button. I increased the text within this and since then half of the text jumps to the next line whenever the viewport is lower than 1200px.
I created a snippet to replicate this, but even that won't help, so this most likely has to be seen live. The area the issue is at is in the "Grow your business with us" section at the very bottom of that section (under the 3 images).
Please view it in a viewport of less than 1200px
What is causing the self made button to be on 2 lines? I have the width set to 100%?
$(function() {
$('#see-all-services-text').animate({
opacity: 1,
left: '0%'
}, 700);
})
#home-img-block-section {
width: 100%;
height: 850px;
}
#see-all-services {
width: 100%;
height: 75px;
text-align: center;
}
#see-all-services-text {
opacity: 0;
font-size: 1.3em;
position: relative;
left: -30%;
}
#see-all-services-text a {
text-decoration: none;
color: #45a5ba;
cursor: pointer;
}
#see-all-services-button {
padding: 15px 20px;
border: 2px solid #45a5ba;
transition: ease-in-out .5s;
}
#see-all-services-button:hover {
border: 2px solid #45a5ba;
color: #FFF;
background: #45a5ba;
transition: ease-in-out .5s;
}
/*---------------------------------------------- MEDIA QUERY 961 - 1200--------------------------*/
#media screen and (min-width: 961px) and (max-width: 1200px) {
#home-img-block-section {
height: 670px;
}
#see-all-services-text {
font-size: 1.2em;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="home-img-block-section">
<div id="see-all-services">
<div id="see-all-services-text"><span id="see-all-services-button">VIEW ALL WEB DESIGN SERVICES</span></div>
</div>
</div>

It's happening because your button is inline element. Set display:inline-block; to it and remove width:100%;, and everything should be ok.
Your snippet:
$(function() {
$('#see-all-services-text').animate({
opacity: 1,
left: '0%'
}, 700);
})
#home-img-block-section {
width: 100%;
height: 850px;
}
#see-all-services {
width: 100%;
height: 75px;
text-align: center;
}
#see-all-services-text {
opacity: 0;
font-size: 1.3em;
position: relative;
left: -30%;
}
#see-all-services-text a {
text-decoration: none;
color: #45a5ba;
cursor: pointer;
}
#see-all-services-button {
padding: 15px 20px;
display: inline-block;
border: 2px solid #45a5ba;
transition: ease-in-out .5s;
}
#see-all-services-button:hover {
border: 2px solid #45a5ba;
color: #FFF;
background: #45a5ba;
transition: ease-in-out .5s;
}
/*---------------------------------------------- MEDIA QUERY 961 - 1200--------------------------*/
#media screen and (min-width: 961px) and (max-width: 1200px) {
#home-img-block-section {
height: 670px;
}
#see-all-services-text {
font-size: 1.2em;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="home-img-block-section">
<div id="see-all-services">
<div id="see-all-services-text"><span id="see-all-services-button">VIEW ALL WEB DESIGN SERVICES</span></div>
</div>
</div>

Related

How to transition image when having border applied

I have an image inside a container, when I apply border to the container, the image is getting smaller, I want to know how to transition this effect? I want to have the same border applied and instead of quick image small, I want to transition it smoothly
.modal-thumb-item {
margin-bottom: 8.5px;
}
.modal-thumb-item {
border: 2px solid transparent;
}
#media screen and (min-width: 769px) {
.thumb-container .modal-thumb-item {
margin-bottom: 15px;
}
}
.item-thumb {
max-width: 100%;
display: block;
position: relative;
cursor: pointer;
}
.item-thumb:hover {
border: 10px solid rgba(0, 0, 0, 0.800);
border-radius: 10px;
}
.thumb-image-wrap {
max-width: 100%;
width: 100%;
}
.active-image-wrap {
padding: 20px;
border-radius: 12px;
}
<div class="modal-thumb-item">
<div id="modal-product-thumb-item" style="border-radius: 10px; height: 100%; overflow: hidden; background: tomato">
<a class="item-thumb">
<img class="thumb-image-wrap active-image-wrap" src="https://www.w3schools.com/html/pic_trulli.jpg" />
</a>
</div>
</div>
You need to add a transition property to your element that gets hovered over.
For example:
.item-thumb {
max-width: 100%;
display: block;
position: relative;
cursor: pointer;
transition: 0.3s; // Add this here
}
.modal-thumb-item {
margin-bottom: 8.5px;
}
.modal-thumb-item {
border: 2px solid transparent;
}
#media screen and (min-width: 769px) {
.thumb-container .modal-thumb-item {
margin-bottom: 15px;
}
}
.item-thumb {
max-width: 100%;
display: block;
position: relative;
cursor: pointer;
transition: 0.3s;
}
.item-thumb:hover {
border: 10px solid rgba(0, 0, 0, 0.800);
border-radius: 10px;
}
.thumb-image-wrap {
max-width: 100%;
width: 100%;
}
.active-image-wrap {
padding: 20px;
border-radius: 12px;
}
<div class="modal-thumb-item">
<div id="modal-product-thumb-item" style="border-radius: 10px; height: 100%; overflow: hidden; background: tomato">
<a class="item-thumb">
<img class="thumb-image-wrap active-image-wrap" src="https://www.w3schools.com/html/pic_trulli.jpg" />
</a>
</div>
</div>
Read more about possible values for the CSS Transition property here

How to keep components auto resizable while creating templates in React JS?

So I am trying to put a background image and then center the text to it, but when I change the screen size the text misaligns and moves to the top.
Here's my code:
import React from "react";
import UniversalValues from "../constants.js";
export default function Body() {
return (
<div>
<div className="Container">
<img
className="ResizeImage"
src="https://images.unsplash.com/photo-1533139143976-30918502365b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max"
alt="Background not loading! X_X"
/>
<div className="TextField">
<h1 className="BGH1">WE DO IT TOGETHER</h1>
<h1 className="BGH1">SO LET'S CREATE</h1>
</div>
</div>
</div>
);
}
Here is my css file:
.App {
font-family: sans-serif;
text-align: center;
}
.BGH1 {
letter-spacing: 0.06em;
font-family: "Cinzel", serif;
font-size: 5rem;
position: relative;
}
.BrandPoint {
font-size: 3rem;
font-family: "Cinzel", serif;
padding-left: 3rem;
}
.Container {
position: relative;
}
.dropbtn {
background: transparent;
color: white;
padding-bottom: 10px;
font-size: 1.2rem;
font-weight: bold;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #33393f;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
.HeaderElem {
color: white;
padding-bottom: 10px;
font-size: 1.2rem;
}
.HeaderElem:hover {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
.HeaderSeperator {
padding-left: 2rem;
}
.HeadUp {
position: fixed;
top: 0;
left: 0;
}
.ResizeImage {
height: auto;
width: 100%;
margin: 0;
padding: 0;
opacity: 0.99;
}
.TextField {
position: absolute;
bottom: 40%;
left: 35%;
color: white;
padding-left: 20px;
padding-right: 20px;
}
What I am getting vs What I wanted:
I want to pack this whole thing together and so it could just effectively change its shape according to the screen size. I have used Bootstrap but I am new to React and designing my entire website on codesandbox.io. Do let me know the best way to do so.
Thanks in advance.
I think your problem is purely HTML/CSS and not so much React. Thanks for flexbox centering content got a lot easier today.
Change your HTML like this:
<div>
<div class="Container">
<div class="imageContainer"></div>
<div class="TextField">
<h1 class="BGH1">WE DO IT TOGETHER</h1>
<h1 class="BGH1">SO LET'S CREATE</h1>
</div>
</div>
</div>
And your CSS like this:
.Container {
display: flex;
justify-content: center;
align-items: center;
background-color:blue;
position: relative;
color: white;
text-align: center;
height: 300px;
}
.imageContainer {
position: absolute;
width: 100%;
height: 100%;
opacity: 0.2;
background-image: url("https://images.unsplash.com/photo-1533139143976-30918502365b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max");
background-position: center center;
}
Here is a fiddle test it: https://jsfiddle.net/gtqna9c1/7/
How it works
Instead of trying to center changing text by absolute positioning it is a lot easier to create conditions where the text is always centered, no matter what. The background image is now a simple background of a div that is covering your whole box.
The fiddle is simplified and coloured for clarity. Feel free to add paddings etc. as you wish.

mobile responsive not working for all of mobile

Im a beginner for the bootstrap, some text are every where, how can i set it
Im trying to make some application its is not a working for all of mobile devices,its only working for iPhone 6+ and nexus 6p
how can i fix it??
html
<div class="progress-bar position" data-percent="48" data-duration="1000" data-color="#63676e,#ec9850"><script>$(".progress-bar").loading();</script></div>
<div id="Main">
<h2 class="text-color-header">Room Utilization</h2>
<h5 class="text-header">9 rooms occupied today</h5>
<div id="container">
<div class="block block-1">
<h1>$ 2,300</h1>
<h5>Today Revenue</h5>
</div>
<div class="block block-2">
<h1>$ 12,100</h1>
<h5>Reservation for next 15 days</h5>
</div>
<div class="block block-3">
<h1>$ 41,000</h1>
<h5>Revenue Todate / Month</h5>
</div>
<div class="block block-4">
<h1>$ 53,100</h1>
<h5>Expected Revenue for this month</h5>
</div>
<!--Menu Part 02-->
<div id="base">
<div class="base-block">
<h4>Payments</h4>
<h1>$ 2,000</h1>
<h5>5 check-outs today</h5>
</div>
<div class="base-block">
<h4>Down Payments</h4>
<h1>$ 300</h1>
<h5>2 Bokings withdown payments</h5>
</div>
</div>
<!-- End of menu Part-->
</div>
</div>
css
body{webkit-overflow-scrolling: touch;}
.text-color-header { margin-top: 250px;}
/* Progress Bar */
.progress-bar {
text-align: center;
height: 150px;
width: 150px;
margin-left: 100px;
}
.progress-bar {
float: left;
width: 0;
height: 100%;
font-size: 12px;
line-height: 20px;
color: #fff;
text-align: center;
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
-webkit-transition: width .6s ease;
-o-transition: width .6s ease;
transition: width .6s ease;
}
.progress-bar div {
position: absolute;
height: 200px;
width: 200px;
border-radius: 50%;
}
.progress-bar div span {
position: absolute;
font-family: Arial;
font-size: 35px;
line-height: 175px;
height: 175px;
width: 175px;
left: 12.5px;
top: 12.5px;
text-align:center;
border-radius: 50%;
background-color:#e0e0e0;
color: black;
}
.progress-bar .background {
background-color: #b3cef6;
}
.progress-bar .rotate {
clip: rect(0 100px 200px 0);
background-color: #4b86db;
}
.progress-bar .left {
clip: rect(0 100px 200px 0);
opacity: 1;
background-color: #b3cef6;
}
.progress-bar .right {
clip: rect(0 100px 200px 0);
transform: rotate(180deg);
opacity: 0;
background-color: #4b86db;
}
#keyframes toggle {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/*End of Progress Bar*/
.page {
margin: 0px auto;
display: flex;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
.clearfix {
display: inline-block;
margin: 0px auto;
}
h5,
.h5 {
font-size: 13px;
text-align: center;
}
.block {
width: 200px;
height: 100px;
margin: 1px;
display: inline-block;
background: ;
color: #d4c4b6;
}
.block:hover h1 {
color: #000000;
}
.block:hover h5 {
color: #A48973;
}
#base {
background: #e2e2e2;
display: inline-block;
height: 120px;
margin-left: 0px;
margin-top: -7px;
position: relative;
width: auto;
}
#base:before {
border-bottom: 35px solid #e2e2e2;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
content: "";
height: 0;
left: 173px;
position: absolute;
top: -20px;
width: 0;
}
h1,
.h1 {
font-size: 27px;
text-align: center;
}
h2,
.h2 {
font-size: 20px;
text-align: center;
}
h4,
.h4 {
font-size: 16px;
text-align: center;
}
.base-block {
display: inline-block;
height: 120px;
width: 200px;
margin: 1px;
display: inline-block;
}
.base-block h1,
h4 {
color: #000000;
}
.base-block h5 {
color: #A48973;
}
.navbar-default .navbar-brand {
color: #A48973;
}
.navbar-default .navbar-toggle {
border: none;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #A48973;
}
.search-bar {
padding: 7px 15px;
}
/*Start Media query*/
#media (max-width: 768px) {
.form-control {
padding: 6px 100px;
}
}
/*End Of Media query*/
Use bootstrap grid layout classes col-xs-6 for div's instead of block-1, block-2. In your css, set width and height in percentages instead of numbers in px.
Also, try not to set height, instead set width.
Use classes like panel and panel-body in each div.
Put entire content in
<div class="container-fluid">
//Create three rows
<div class="row">
//create 2 divs with class col-xs-6
</div>
<div class="row">
//create 2 divs with class col-xs-6
</div>
<div class="row">
//create 2 divs with class col-xs-6
</div>
</div>
I couldn't add a comment so I'll just compound with Amit's answer. Make sure this
<meta name="viewport" content="width=device-width, initial-scale=1" /> is in your head tags as well. It set you page viewport size to the px size of device. Without it the code Amit suggested won't work. All in all your not actually using any Bootstrap in your code. I would also recommend looking through this to get a true understanding of Bootstrap https://www.w3schools.com/bootstrap

Setting viewport or optimize code

I have a problem here, than I often run into. I have this small landingpage:
Small Landingpage
When I look at the following viewports:
Iphone 6 & 6+ landscape
Ipad portrait and landscape
the form is not fitting.Is that because of bad coding, or is it just like this? Which means that there always will be some editing regarding viewports?
#import url(https://fonts.googleapis.com/css?family=Questrial);
html,
body {
height: 100%;
background: center no-repeat fixed url('../images/bg_1.jpg');
background-size: cover;
color: #444;
font-family: 'Questrial', sans-serif;
}
#media (min-width: 768px) {
h1 {
font-size: 68px;
}
}
a {
color: #999;
}
a:hover {
color: #111;
}
.catchy-text-wrapper {
width: 100%;
text-align: center;
}
#catchyText {
background-color: red;
padding: 20px;
background: rgba(32, 63, 86, 0.8);
display: inline-block;
}
#emailNews {
font-size: 20px;
}
/* Round corners on button */
.btn,
.well,
.panel {
border-radius: 0;
}
.btn-blue {
background: rgba(32, 63, 86, 1.0);
border-color: #5491bd;
border-radius: 10px;
color: #fff;
}
.btn-huge {
padding: 17px 22px;
font-size: 22px;
}
section {
padding-top: 70px;
padding-bottom: 50px;
min-height: 100%;
min-height: calc(100% - 0);
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
#section1 {
background-color: rgba(0, 0, 0, 0.6);
color: #fff;
}
/* Form Config */
input {
font-size: 16px;
min-height: 40px;
border-radius: 25px;
line-height: 20px;
padding: 15px 30px 16px;
border: 1px solid #b9b9af;
margin-bottom: 10px;
background-color: #fff;
opacity: 0.9;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.subscribe-input {
float: center;
width: 23%;
height: 5px;
text-align: left;
margin-right: 2px;
}
.btn-placing {
padding-top: 20px;
"
}
#media screen and (max-width: 767px) {
.subscribe-input {
width: 100%;
}
}
<section class="container-fluid" id="section1">
<div class="v-center">
<h1 class="text-center">COMPANY NAME</h1>
<h2 class="text-center">Change this <b>subline</b> here</h2>
<div class="catchy-text-wrapper">
<h2 class="text-center" id="catchyText">A CATCHY PIECE OF TEXT</h2>
</div>
<br>
<p class="text-center"><i id="emailNews">Enter your email for more news</i>
</p>
</div>
<div class="catchy-text-wrapper">
<form role="form" action="register.php" method="post" enctype="plain">
<input type="email" name="email" class="subscribe-input" placeholder="Enter your e-mail address..." required>
</form>
</div>
<p class="text-center btn-placing">
Give me the news
</p>
</section>
Your <input> is displaying at its default box-sizing: content-box, which means that when your
#media screen and (max-width: 767px) {
.subscribe-input {
width: 100%;
}
}
is applied, the content box is getting sized to 100%. Padding is outside the content box, so when you add in the
input {
padding: 15px 30px 16px;
}
your <input> is 60px wider than its container.
Get around this by adding box-sizing: border-box to your input's styles.

on hover changing other element's css properties not working

I'm working on some project and I've been trying to display a button after my whole element gets hovered. I think I'm using the right syntax, but things are not really working, I need help.
Code:
<div class="upgrade">
PURCHASE UPGRADE
<a href="#">
<div class="upgradeFooter">
<span>example</span>
</div>
</a>
</div>
.upgrade {
width: 24%;
height: 48%;
background: url('../background.jpg');
margin-right: 1%;
float: left;
margin-bottom: 2%;
transition: background 0.5s;
}
.upgrade:hover {
background: #d20a30;
}
.upgrade:hover ~ a.purchaseButton {
opacity: 1;
filter: alpha(opacity=100);
}
a.purchaseButton {
text-transform: uppercase;
background: #EEEEEE;
color: #000;
font-weight: 400;
padding: 15px;
margin-top: 100px;
margin-left: 18%;
float: left;
border-radius: 5px;
transition: background 0.5s;
opacity: 0;
filter: alpha(opacity=0);
}
a.purchaseButton:hover {
background: #ccc;
}
.upgradeFooter {
background: rgba(0, 0, 0, 0.3);
height: 20%;
margin-top: 25%;
box-sizing: border-box;
transition: background 0.5s;
float: left;
width: 100%;
}
.upgradeFooter span {
padding: 19px 0;
width: 100%;
float: left;
text-align: center;
font-weight: 400;
text-transform: uppercase;
color: #fff;
}
.upgradeFooter:hover {
background: #d20a30;
}
Code in JSFiddle
I hope that you guys help me out, thanks in advance.
The problem is in
.upgrade:hover ~ a.purchaseButton
if you remove the ~ all will be working just fine.