Expand div to the right css [closed] - html

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 5 years ago.
Improve this question
.icon1 {
float: left;
width: 0;
height: 0;
border-bottom: 100px solid red;
border-right: 100px solid transparent;
}
.text1 {
float: right;
width: 0;
height: 0;
border-bottom: 100px solid transparent;
border-right: 100px solid red;
right: 50px solid red;
}
<div class="content">
<div class= "icon1"></div>
<div class= "text1"></div>
</div>
I want to make the text1 div expand to the right, I think a screenshot will help:
Can you guys help me? I want the left triangle to be a rectangle without the left-bottom-corner.

Not sure if this works for you, just hacked this together real quick:
.content {
overflow: hidden;
box-sizing: border-box;
display: inline-block;
height: 120px;
padding: 10px;
background: #fff;
}
.icon1 {
float: left;
}
.icon1::before {
content: " ";
float: left;
height: 0;
width: 0;
border-top: 100px solid transparent;
border-left: 100px solid #f00;
}
.icon1::after {
content: " ";
float: left;
width: 0;
height: 0;
margin-left: -70px;
border-right: 100px solid #f00;
border-bottom: 100px solid transparent;
}
.text1 {
float: left;
height: 100%;
padding: 0 1em;
line-height: 80px;
color: #fff;
background: #f00;
font-family: sans-serif;
font-weight: bold;
}
<div class="content">
<div class= "icon1"></div>
<div class= "text1"><p>I'm some text within a fancy box.</p></div>
</div>
Bazinga.
EDIT: Completely reworked this based on OP's newest picture reference. Didn't try it in any other browser, not sure if this will hold up well. Looking good for me on FF though.

Related

Getting rid of gray background in CSS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
In this image, how do I get rid of the gray background that automatically appears when I create my CSS header?
.header {
padding: 60px;
margin: 20px auto auto auto;
width: 1400px;
border-radius: 10px;
text-align: center;
background: #1abc9c;
color: white;
}
body {
background: #f2f2f2;
}
.search {
width: 100%;
position: relative;
display: flex;
}
.searchTerm {
width: 4500px;
border: 3px solid #1abc9c;
border-right: none;
padding: 5px;
height: 50px;
border-radius: 5px 0 0 5px;
outline: none;
color: #fff;
}
.searchTerm:focus {
color: black;
}
.searchButton {
width: 50px;
height: 50px;
border: 1px solid #1abc9c;
background: #1abc9c;
text-align: center;
color: #fff;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
/*Resize the wrap to see the search bar change!*/
.wrap {
width: 30%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 900px;
margin: auto;
}
<div class="header">
<h1 style="font-size: 100px;">HI</h1>
<p style="font-size: 30px;">
Hello
</p>
</div>
<div class="wrap">
<div class="search">
<input type="text" class="searchTerm" id="input_text" />
<button type="submit" class="searchButton" onclick="send_text()">
<i class="fa fa-search"></i>
</button>
</div>
</div>
<div class="search"></div>
Thanks!
When I add this CSS and HTML I start getting that gray background around the header. However when I comment out the code for the search bar the header does not have the gray background.
The reason is because you are using this in your css, it is creating greyish background in your html:
body {
background: #f2f2f2;
}
Сheck that the html has a class .header
Try changing the background-color of the .header and see what happens
Try setting the background-color for the body and see what happens

How to fix the triangle alignment issue and i don't what wrong in my code [duplicate]

This question already has answers here:
Shape with a slanted side (responsive)
(3 answers)
Closed 4 years ago.
I have to draw half diagonal triangle in card i tried but i don't know how to bring the exact output as shown in this image and i have uploaded my code too, so please if anyone know how to achieve as same like image please let me know for reference i have upload the excepted output image here Output
.cards{
border-bottom: 148px solid red;
border-left: 158px solid transparent;
}
.empty-space-section6 {
height: 411px;
width: 230px;
border-color: gray;
margin-left: 20px;
margin-top: 16.5px;
margin-bottom: 52.5px;
background-color: #FFFBE2;
}
<div class="empty-space-section6">
<div class="cards">
</div>
</div>
You need to increase border width and set alignment to right to achieve this. Check updated snippet below:
.cards {
border-bottom: 180px solid red;
border-left: 280px solid transparent;
float: right;
}
.empty-space-section6 {
height: 411px;
width: 230px;
border-color: gray;
margin-left: 20px;
margin-top: 16.5px;
margin-bottom: 52.5px;
background-color: #FFFBE2;
overflow: hidden;
}
<div class="empty-space-section6">
<div class="cards">
</div>
</div>
You can work with positioning to achieve this.
.cards{
border-bottom: 248px solid red;
border-left: 358px solid transparent;
position: absolute;
bottom: 0;
left: -50px;
}
.empty-space-section6 {
height: 411px;
width: 230px;
border-color: gray;
margin-left: 20px;
margin-top: 16.5px;
margin-bottom: 52.5px;
background-color: #FFFBE2;
position: relative;
overflow: hidden;
}
<div class="empty-space-section6">
<div class="cards">
</div>
</div>
I would consider to use instead a simple linear-gradient as the background so you wouldn't need to mess with borders.
e.g.
article {
width: 240px;
height: 360px;
box-shadow: 0 0 5px #999;
background: linear-gradient(-25deg, #9864bb 160px, #ffffff 162px);
}
<article></article>
In this example the gradient starts from bottom to top but of course you can change how it is anchored and the color-stop values.

How to move triangle over to the center right side of the screen in css?

This may be a silly question, but I have the following code in html:
<h1 class="page-title">
Paintings
</h1>
<hr>
</header>
<div class="arrow1">
<div class="triangle-right">
</div>
</div>
and this in css:
.page-title {
font-size: 75px;
text-align: center;
font-weight: 100;
font-family: 'Quicksand', sans-serif;
margin: 0 auto;
}
.triangle-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-left: 40px solid red;
border-bottom: 30px solid transparent;
}
The triangle sits in the top corner of the screen, right below the header. I want to move it over to the right side of the screen and in the center. I also want to create another triangle on the left side and do the same.
My goal here is to create two triangle buttons. Can someone help me achieve this?
I'm not quite sure what you mean by having it center, like horizontally or vertically, but here is a solution that you might find helpful :)
.page-title {
font-size: 75px;
text-align: center;
font-weight: 100;
font-family: 'Quicksand', sans-serif;
margin: 0 auto;
}
.triangle-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-left: 40px solid red;
border-bottom: 30px solid transparent;
float: right;
}
.triangle-left {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-right: 40px solid red;
border-bottom: 30px solid transparent;
float: left;
}
.arrow1 {
margin-top: 100px;
}
<h1 class="page-title">Paintings</h1>
<hr>
<div class="arrow1">
<div class="triangle-left"></div>
<div class="triangle-right"></div>
</div>
At the moment i've just set the margin-top: 100px; you can just adjust it so it fits what you want :)
jsfiddle
Hope this one helps. M not sure what you want exactly.
display: inline-block;
use that display;

Looking to create a 3 image hexagon grid like this [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 6 years ago.
Improve this question
I just finished some courses in HTML and CSS, but I am clueless about how to create hexagons. I'm looking to create something like this using HTML and CSS:
This is what it looks like:
Thank you,Robert.
ps. I scored the web and stackoverflow, but did not find anything close.
All I found were big-huge hexagon grids, but any attempt to adjust resulted in loss of structure.
I would do something like this. Just see what I did with the middle and then apply that to the rest. Check out https://jtauber.github.io/articles/css-hexagon.html
.content {
width: 500px;
height: 500px;
background-color: #efefef;
z-index: 1;
}
.hex {
float: left;
margin-left: 3px;
margin-bottom: -26px;
}
.hex .top {
width: 0;
border-bottom: 30px solid #6C6;
border-left: 52px solid transparent;
border-right: 52px solid transparent;
}
.hex .middle {
width: 96px;
height: 60px;
background: transparent;
border: 4px solid #6C6;
}
.hex .bottom {
width: 0;
border-top: 30px solid #6C6;
border-left: 52px solid transparent;
border-right: 52px solid transparent;
}
.hex-row {
clear: left;
}
.hex-row.even {
margin-left: 53px;
}
<br/><br/>
<div class="content">
<div class="hex-row">
<div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div>
<div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div>
<div class="hex"><div class="top"></div><div class="middle"></div><div class="bottom"></div></div>
</div>
</div>

CSS differences between Firefox and Chrome - vertical height [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm having some trouble getting Firefox and Chrome to display a small section of CSS properly.
I've broken it down as much as possible and created a Codepen to illustrate the problem.
When viewed in Firefox, everything displays as intended (vertically centered). With Chrome, the labels are slightly too high, by one or two pixels.
Everything I've tried so far (adjusting padding, changing floats, adding inline-block, adding margins) will always display incorrectly in one of the two browsers.
What I'd like to know then is what the root cause of the issue is. I use a CSS reset (normalise.css) which is added to the Pen.
Link: Codepen
<div class="editbox">
<div class="object objecthover edit">
<label class="t">Edit</label>
</div>
<div class="object objecthover lock">
<label class="text_label">Lock</label>
<label class="gems index-gems">50 </label>
</div>
</div>
.editbox {
position: absolute;
height: 60px;
width: 192px;
background-color: #516580;
padding-top: 12px;
left: 0px;
}
* {
box-sizing: border-box;
}
.edit, .save {
min-width: 50px;
padding: 7px;
}
.editbox label {
-moz-user-select: none;
color: #FFF;
height: 35px;
}
.editbox .object {
position: relative;
border: 2px solid #FFF;
display: inline-block;
padding: 4px;
margin-left: 4px;
height: 35px;
text-align: center;
}
div.lock {
width: 130px;
height: 35px;
padding: 5px 1px 5px 0px;
}
.lock .text_label {
display: inline-block;
}
.editbox label {
-moz-user-select: none;
color: #FFF;
height: 35px;
}
.lock label.index-gems {
padding: 0px;
}
label.index-gems {
color: #FFF;
height: 27px;
padding: 4px;
}
.editbox .lock::after, .editbox .make_bid::after {
content: "";
position: absolute;
top: 33px;
height: 0px;
width: 0px;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #FFF;
}
Trying to vertically align text using padding is unreliable. Two better ways are
use display: table-cell and vertical-align: middle
set the line-height of your element to the same as the height.
The first option handles multi-line text where the second doesn't, but introducing table cells can lead to other layout issues. If you're only ever dealing with a single line of text, the second option is more straightforward.
Here's an example of using line-height to vertically align text:
div {
display:inline-block;
border:1px solid #abc;
}
.a {
line-height: 20px;
height: 20px;
}
.b {
line-height: 30px;
height: 30px;
}
.c {
line-height: 40px;
height: 40px;
}
.d {
line-height: 50px;
height: 50px;
}
.e {
line-height: 60px;
height: 60px;
}
<div class="a">text</div>
<div class="b">text</div>
<div class="c">text</div>
<div class="d">text</div>
<div class="e">text</div>