Hello i have a background which i want to add div over it like this picture
im using bulma css framework
i was able to achive this look by writing this code
index.html
<div class="section newsletter">
<figure class="image">
<img src="src/img/newsletter.png">
</figure>
<div class="form">
<h5>Keep updated with out latest news.<br>Subscribe to our newsletter</h5>
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="Enter Your Email">
</div>
<div class="control">
<a type="button" class="button btn-grad is-dark">
Subscribe
</a>
</div>
</div>
</div>
</div>
css
.newsletter{
padding:0px;
.form{
display: flex;
flex-direction: column;
width:588px;
height:297px;
background: $bg-transperant;
box-shadow: 0px 5px 14px rgba(0, 0, 0, 0.15);
border-radius: 16px;
// Layout
position: relative;
left: 140px;
top: -386px;
h5{
padding: 50px 60px 40px 60px;
font-weight: 600;
font-size: 25px;
line-height: 46px;
color: #2F4B6E;
}
div{
justify-content: center;
}
.input{
height: 50px;
width: 352px;
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.15);
border-bottom-left-radius: 100px;
border-top-left-radius: 100px;
}
}
}
the problem is that itsn't responsive in mobile or tablet
it looks like this
im using position relative to able to put the div on the top of the image
how can i do it better for example to make it responsive ?
also there is a large white space below the picture i don't know why
Live Project Repo https://github.com/Ov3rControl/ReachGate
Live Overview: https://ov3rcontrol.github.io/ReachGate/
This may be 3 problems combined.
1) Ensure that you have your viewport set to responsive in the head
2) Don't use hard-coded dimensions for containers that expand beyond the smallest possible viewport. Notice your form is set to a 588px width. Try doing width: auto; and then max-width: 588px; instead.
3) Consider not hard-coding your positioning. Try something like this instead to center relatively positioned containers.
Looking really pretty though, good job! One aside: It's considered good practice to always tie a label to an input for accessibility purposes. If you don't want it visible that's fine! See this
I did the following to responsively center the form:
<!------------------------------------[NewsLetter Section - START]------------------------------------------->
<div class="section newsletter">
<div class="form">
<h5>Keep updated with our latest news.<br>Subscribe to our newsletter</h5>
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="Enter Your Email">
</div>
<div class="control">
<a type="button" class="button btn-grad is-dark">
Subscribe
</a>
</div>
</div>
</div>
</div>
<!------------------------------------[NewsLetter Section - END]------------------------------------------->
.newsletter {
padding: 0px;
background-image: url('src/img/newsletter.png');
height: 400px;
display: flex;
align-items: center;
justify-content: center;
.form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
max-height: 270px;
max-width: 320px;
background: $bg-transperant;
box-shadow: 0px 5px 14px rgba(0, 0, 0, 0.15);
border-radius: 16px;
// Layout
h5 {
padding: 50px 60px 40px 60px;
font-weight: 600;
font-size: 25px;
line-height: 46px;
color: #2f4b6e;
}
div {
justify-content: center;
}
.input {
height: auto;
height: 50px;
width: 352px;
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.15);
border-bottom-left-radius: 100px;
border-top-left-radius: 100px;
}
}
}
Related
You can see in the picture below, it displays normally on desktop, but changes on a mobile view.
I created this box with a span and added some objects in it, but I noticed, and don't know why it will show properly on PC and changes shape on Mobile even after setting the overflow-x to scroll. Someone help me with this please.
See the image here.
This is the html code:
```
<div>
<div class="suggestion_container">
<span class="suggestion-box">
<img class="sug-img" src="images/legion.png">
<h1 class="sug-name">Legion Network</h1>
<h2 class="sug-price">800,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/holo.png">
<h1 class="sug-name">Holo</h1>
<h2 class="sug-price">800,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/safepal.png">
<h1 class="sug-name">SafePal</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/kava.png">
<h1 class="sug-name">Kava</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/compound.png">
<h1 class="sug-name">Compound</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
</div>
</div>```
This is the css style:
.sug-img {
padding: 6px 0px 0px 6px;
width: 40px;
height: 40px;
}
.sug-name {
font-size: 18px;
margin-top: 50px;
position: absolute;
left: 6px;
}
.sug-price {
font-size: 18px;
margin-top: 75px;
position: absolute;
left: 6px;
}
.suggestion-box {
position: relative;
height: 100px;
width: 152px;
background-color: white;
margin-right: 12px;
border-radius: 10px;
display: flex;
border: 1px solid;
}
.suggestion_container {
display: flex;
padding-top: 70px;
margin: -70px 20px 0px 20px;
overflow-x: scroll;
white-space: nowrap;
}
The width CSS attribute is overridden for items inside a display:flex container.
You can either:
add a min-width: 150px to .suggestion-box, this will ensure that the item's width can get shrunk, but never below 150px
add flex-shrink: 0 and flex-basis: 150px to .suggestion-box which will render the items at 150px to begin width, but will never shrink below that value, only grow.
Both approaches will end up with the same result.
.suggestion-box {
position: relative;
height: 100px;
flex: 1 0 150px;
background-color: white;
margin-right: 12px;
border-radius: 10px;
display: flex;
border: 1px solid;
}
I have tried to create a box for my specific content and I want a white background in that. On the other hand, I want a gradient background on the whole screen except that box.
After I tried it, I only got white background on the whole screen.
Here is the related HTML and CSS.
.div1{
position: absolute;
top: 46%;
left: 50%;
margin-top: -50px;
margin-left: -100px;`enter code here`
border: 1px solid red;
border-radius: 25px;
}
<body>
<div class="div1 text-center">
<h1 class="heading">Weather App</h1>
<form method="post" action="/" class="">
<label class="askingInfo" for="cityInput">City Name : </label>
<input id="cityInput" type="text" name="cityName">
<button class="btn-lg btn-outline-primary" type="submit">Go</button>
</form>
</div>
</body>
You could give the gradient background to body so it can fill the whole screen except that box. Something like that:
body {
background: linear-gradient(
171deg,
rgba(0, 0, 0, 1) 40%,
rgba(110, 110, 110, 1) 100%
)
};
The body has the gradient on it.
The div has a background of white.
I would also recommend using a fieldset tag around the form to indicate semantically that everything inside it is related.
Here is a codepen showing the outcome. Codepen
Alternatively, this is the code
body{
width: 100vw;
max-width: 1800px;
height: 100vh;
//This is the Background we set
background-image: radial-gradient(circle at center center, transparent,rgb(33,33,33)),repeating-linear-gradient(135deg, rgb(33,33,33) 0px, rgb(33,33,33) 2px,transparent 2px, transparent 10px,rgb(33,33,33) 10px, rgb(33,33,33) 11px,transparent 11px, transparent 21px),repeating-linear-gradient(45deg, rgb(47,47,47) 0px, rgb(47,47,47) 4px,transparent 4px, transparent 8px),linear-gradient(90deg, rgb(33,33,33),rgb(33,33,33));
}
.div1{
position: absolute;
display: flex;
left: 25vw;
top: 25vh;
flex-direction: column;
justify-content: center;
align-items: center;
width: 25vw;
height: 25vh;
padding: 1.5rem 0.5rem;
border-radius: 25px;
background: white;
}
fieldset{
border: 1px solid rgb(92, 84, 62);
border-radius: 25px;
padding: 1rem;
width: 80%;
height: 90%;
}
legend{
font-size: 1.4rem;
font-weight: bold;
background: white;
border-radius: 25px;
padding: 5px 10px;
border: 1px solid rgb(92, 84, 62);
}
input:focus{
background: rgb(212, 255, 254);
}
<body>
<div class="div1 text-center">
<fieldset>
<legend class="heading">Weather App</legend>
<form method="post" action="/" class="">
<label class="askingInfo" for="cityInput">City Name :
<input id="cityInput" type="text" name="cityName">
</label>
<button class="btn-lg btn-outline-primary" type="submit">Go</button>
</form>
</fieldset>
</div>
</body>
Hi I am designing a blog site using pure html and css and I have some design in mind. Currently it looks like before graph and I would like to achieve after graph. Right now all these classes are in inline-block and I do not want to change the dom structure. Please refer to this code snippet for implementation:
https://jsfiddle.net/yueeee/vb1we2tk/4/
.container {
padding: 10px 40px;
padding-left: 0px;
width: 100%;
height: 100%;
}
.meta {
position: relative;
display:inline-block;
height: 100%;
width: 10%;
max-width: 200px; /*in large resolution dont always want width to be 12%*/
margin-right: 40px;
/* background-color: transparent; */
padding: 0px 10px;
text-align: right;
vertical-align:top; /*always align to the top of container*/
}
.content {
width: 30%;
display:inline-block;
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
vertical-align:top; /*always align to the top of container*/
}
<div class="container">
<div class="meta">
<div class="time">
<p>2020/12/09<br>22:18:35</p>
</div>
<div class="tag">
<p>tag1</p>
<p>tag2</p>
</div>
</div>
<div class="content post">
<div class="text">
<h2> title </h2>
<p>content<br>content<br>content<br>content<br>content<br>
</p>
</div>
</div>
</div>
The difficulty I met is how do I set metadata's height equals to content. I checked solution on setting container as table and metadata/ content as table-cell. However, it would cause some other styling issue so I still want to keep everything as inline-block. The other way I am thinking is to set the height of metadata equal to container. It failed because container does not height attribute. I tried something like setting height = 100% cause I do not want a stable height but also did not work.
Need your advice.
Before:
After:
The best choice in these cases is to use the flex property. I added some Properties to both the .container and .meta selectors and deleted some, act like code to get the desired result.
.container {
display: flex;
padding: 10px 40px;
padding-left: 0px;
width: 100%;
height: 100%;
}
.meta {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 10%;
margin-right: 40px;
padding: 0px 10px;
text-align: right;
}
.content {
width: 30%;
display:inline-block;
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<div class="container">
<div class="meta">
<div class="time">
<p>2020/12/09<br>22:18:35</p>
</div>
<div class="tag">
<p>tag1</p>
<p>tag2</p>
</div>
</div>
<div class="content post">
<div class="text">
<h2> title </h2>
<p>content<br>content<br>content<br>content<br>content<br>
</p>
</div>
</div>
</div>
I am trying to make a fintech application and I am using a mockup from an already existing application as my own UI. I need it to look as professional as possible. I have a bit of a problem though. My application has a card in one of the sections. On PC, it looks fine but it moves out from its original position on mobile. I have added media queries but they are not helping.
It's my codes:
.card-container {
position: relative;
}
.card-tip {
width: 290px;
height: 16px;
background-color: rgba(223, 186, 129, 0.6);
margin: 30px auto 0 auto;
border-radius: 40px;
}
.card-tip span {
width: 250px;
height: 3px;
display: block;
background-color: #8F6524;
margin: auto;
transform: translateY(6px);
}
.card {
width: 260px;
height: 350px;
background-color: white;
margin-left: 40.5%;
box-shadow: 3px 3px rgba(32, 30, 30, 0.3);
transform: translateY(-9px);
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
<section id="feature-section">
<h1>It's free to send money</h1>
<p>It costs nothing to send money, when you link your Paga wallet to your bank account.</p>
<div class="card-container">
<div class="card-tip">
<span></span>
</div>
<div class="card">
<h6>Your receipt</h6>
<i class="fas fa-chevron-circle-up"></i>
<p>₦<span>0</span>.00</p>
<h6>No transfer fee</h6>
<h6>No 'convenience' fee</h6>
<h6>No hidden charge</h6>
<img src="images/rocket.png" alt="">
</div>
</div>
</section>
The completed web page can also be locked viewed through this link: https://chinomso1995.github.io/mini-fintech-application.
Just click on send money. Its the first link Item.
The card shifts on mobile.
it's not right to use margin-left to center items. You can use margin: auto to center items exactly.If you use margin-left to average items with each other, you will have to adjust them all again for each size ( tablet, mobile). a method is not correct.
I also used the display:flex structure to bring the card down and down without overflow.
No matter what size they are, there will be no overflow because I use Display flex.
.card-container {
position: relative;
display: flex;
flex-direction: column;
margin: auto;
}
.card-tip {
width: 290px;
height: 16px;
background-color: rgba(223, 186, 129, 0.6);
margin: 30px auto 0 auto;
border-radius: 40px;
}
.card-tip span {
width: 250px;
height: 5px;
display: block;
background-color: #8F6524;
margin: auto;
transform: translateY(6px);
}
.card {
width: 260px;
height: 350px;
background-color: #000234;
box-shadow: 1px 1px 1px rgba(32, 30, 30, 0.3);
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
margin: auto;
color: #fff;
display:flex;
flex-direction:column;
align-items:center;
<section id="feature-section">
<h1>It's free to send money</h1>
<p>It costs nothing to send money, when you link your Paga wallet to your bank account.</p>
<div class="card-container">
<div class="card-tip">
<span></span>
</div>
<div class="card">
<h6>Your receipt</h6>
<i class="fas fa-chevron-circle-up"></i>
<p>₦<span>0</span>.00</p>
<h6>No transfer fee</h6>
<h6>No 'convenience' fee</h6>
<h6>No hidden charge</h6>
<img src="images/rocket.png" alt="">
</div>
</div>
</section>
My project uses a 20 row by 20 column css grid layout (5% of screen for each cell). One of the pages has a button. Originally the page was contained within grid columns 5-8 and grid rows 6-9, and there was no problem with the button itself, but I need to center it within the grid area, so I used flexbox for centering within the css grid.
The button text is "Select file to upload" but problem is that the button is now only the width of a single word; I want the button to be as wide as all four words. Before I added a flex container for centering the button was as wide as all four words but now with the flex container it's not.
The flexbox arrangement works perfectly for all other elements on the page and two other pages, but this button has that problem (on Firefox 64). I may need to use a unique flex-item class for it, different from the flex-item class shown below.
Here are the css classes that apply to this button:
.center_text_grid {
display: grid;
grid-column: 5 / 12;
grid-row: 6 / 19;
display: block;
overflow: auto;
align-items: center;
justify-items: center;
}
.flex-item {
display: flex;
width: 70%;
flex-direction: row;
align-items: center;
justify-content: center;
}
.upload-btn-wrapper {
display: inline-block;
text-align:center;
border-radius: 15px;
}
.btn {
border: 1px solid rgb(117,163,126);
background-color: black;
width: 75%;
padding: 8px 20px;
border-radius: 15px;
font-size: 20px;
font-weight: bold;
font-family: CamphorW01-Thin, sans-serif;
font-size: 13pt;
color: rgb(117,163,126);
cursor: pointer;
}
Here is the html for this button:
<div class="center_text_grid flex-item">
<div class="upload-btn-wrapper">
<button class="btn" style="width: 100%">Select file to upload</button>
<input type="file" name="fileToUpload" />
</div></div><br><br>
I know this is not a complete reproducible example but as this is specific to button styling, I hoped it could be answered with the code above.
Thanks for any help.
Here's how I solved this:
<div class="upload-btn-wrapper center_text_grid flex-item">
<button class="btn">Select file to translate</button>
<input type="file" name="fileToUpload" />
</div><br><br>
As posted in my original question, this html code wrapped the button in two divs. I changed to a single div and added the upload-btn-wrapper class to the single div. I also changed width in the .btn class to 65%.
That leaves only one problem to resolve: the btn class has a hover selector, but the button text is not highlighted on hover:
.btn:hover{
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: 0px 0px 10px 0px rgba(0, 255, 0, 0.67);
-moz-box-shadow: 0px 0px 10px 0px rgba(0, 255, 0, 0.67);
box-shadow: 0px 0px 10px 0px rgba(0, 255, 0, 0.67);
color: rgb(175,222,162);
}
This is a file selection button so it's handled differently from other buttons, but I don't know how to do it yet. I'll post the answer to that one when I have it. If anyone else knows, please let us know.
Thanks to those who answered.
I copied your code to a jsfiddle and have it below. It works fine on Stack Overflow and jsfiddle. It could your browser not supporting a line of code, causing the code to not work properly. I suggest updating your browser, or switching to a different browser.
Hope this helps!
.center_text_grid {
display: grid;
grid-column: 5 / 12;
grid-row: 6 / 19;
display: block;
overflow: auto;
align-items: center;
justify-items: center;
}
.flex-item {
display: flex;
width: 70%;
flex-direction: row;
align-items: center;
justify-content: center;
}
.upload-btn-wrapper {
display: inline-block;
text-align: center;
border-radius: 15px;
}
.btn {
border: 1px solid rgb(117, 163, 126);
background-color: black;
width: 75%;
padding: 8px 20px;
border-radius: 15px;
font-size: 20px;
font-weight: bold;
font-family: CamphorW01-Thin, sans-serif;
font-size: 13pt;
color: rgb(117, 163, 126);
cursor: pointer;
}
<div class="center_text_grid flex-item">
<div class="upload-btn-wrapper">
<button class="btn" style="width: 100%">Select file to upload</button>
<input type="file" name="fileToUpload" />
</div>
</div><br><br>
Remove styles for both button and input
wrap them in a div.
Add the button css styles to the div.
Example button CSS -
.divButton {
background-color: cyan;
border: none;
color: white;
padding: 12px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}