I have to class
<div class="thread-entryresponse">
<div class="date">
</div>
</div>
then
<div class="thread-entrymessage">
<div class="date">
</div>
</div>
my css code is
.thread-entryresponse {
border-left: 2px solid #428bca;
color: #444;
padding: 10px;
}
.thread-entrymessage {
border-right: 2px solid #444;
}
.date {
color: #444;
margin-top: 20px;
padding: 10px;
}
I am trying to do below
if .thread-entryresponse and .date then border-left: 2px solid #428bca; on the date
if .thread-entrymessage and .date then border-right: 2px solid #444;
on the date
note that the date is inside of the thread-entryresponse and thread-entrymessage
First, I strongly recommend you learn basics in HTML/CSS
Second, you can use this
DEMO
.thread-entryresponse .date {
border-left: 2px solid #428bca;
}
.thread-entrymessage .date {
border-right: 2px solid #444;
}
As you say:
.date is inside of the .thread-entryresponse and .thread-entrymessage
This means that .date is a descendant of .thread-entryresponse and .thread-entrymessage. To vary the style of .date according to its parent, use the descendant selector:
Markup:
<div class="thread-entryresponse">
<div class="date"></div>
</div>
<div class="thread-entrymessage">
<div class="date"></div>
</div>
CSS:
.thread-entryresponse .date {
border-left: 2px solid #428bca;
}
.thread-entrymessage .date{
border-right: 2px solid #444;
}
Demo
Related
I have the following code snippet:
h2 { padding: 0; margin: 0; }
.middle-bar { background-color: #b0b0b0; border-bottom: 2px solid black; }
.middle-bar h2 { border-bottom: 1px solid white; border-right: 1px solid white; display: inline-block }
.above-main { display: inline-flex; }
<div class="middle-bar">
<h2>TEST</h2>
<div class="above-main">
<span>test test 123</span>
</div>
</div>
I am trying to get it so that the parent (middle-bar) bottom-border does not pass under the <h2> element (so as to use the <h2> border-bottom for that section).
If I set the border-bottom: 2px solid black; to above-main class, it only underlines test test 123. If I set above-main to display: block; (or display: flex;), it acts like a block element is supposed to and makes a new line below the <h2>.
Does anyone know how to get the border-bottom: 1px solid white; from the child element <h2> to "override" the border-bottom: 2px solid black; from the parent .middle-bar element?
Thank you.
Set the border bottom on the above-main div instead of the outer div.
Edit: as you have already tried that:
Does margin-bottom: -1px on the h2 solve it?
Maybe you want this?
h2 { padding: 0; margin: 0; }
.middle-bar .above-main { background-color: #b0b0b0; border-bottom: 2px solid black; }
.middle-bar h2 { border-bottom: 1px solid white; border-right: 1px solid white; display: inline-block }
.above-main { display: inline-flex; }
<div class="middle-bar">
<h2>TEST</h2>
<div class="above-main">
<span>test test 123</span>
</div>
</div>
HTML:
<!-- start setup section -->
<div class='photo-setup'>
<div class='setup-head'>
<div class='photo-name'>Photo Name : <input type='text' placeholder='Photo Name' name='photo-name' title='Photo Name'></div>
<div class='photo-date'>Photo Date : <?php echo date('F j, o', time()) ?></div>
</div>
<div class='photo-section'>
<img src='' width='600' height='600' alt='photo'>
</div>
<div class='tag-section'>
Tags : <input type='text' placeholder='Tags e.g. (#beach #park #dog)'>
</div>
<div class='commit-section'>
<a class='save' href='#'>Save</a><a class='cancel' href='#'>Cancel</a>
</div>
</div>
<!-- end setup section-->
CSS:
img { border: none; }
.photo-setup {
width: 600px;
height: auto;
margin: 0 auto;
}
.setup-head {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
border-top: 1px solid #cacece;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 1em;
}
.photo-name { float: left; }
.photo-date { float: right; }
.photo-section {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
}
Result: https://jsfiddle.net/rw5beqtk/
Question 1: Why is the top and bottom padding in setup-head not the same?
Question 2: Why is the border of photo-section not the same as setup-head?
Question 1: Why is the top and bottom padding in setup-head not the
same?
Because your child element is floated and as such taken out of the normal flow. Setting overflow:hidden on setup-head will fix that.
.setup-head {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
border-top: 1px solid #cacece;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 1em;
overflow: hidden;
}
Question 2: Why is the border of photo-section not the same as
setup-head?
It is the photo-section's img child's border, so you get double. When an img element doesn't have a valid src, it gets a border representing the image size, which won't go away with border: none.
Sample snippet with an image and overflow: hidden
img {
border: none;
vertical-align: top;
}
.photo-setup {
width: 600px;
height: auto;
margin: 0 auto;
}
.setup-head {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
border-top: 1px solid #cacece;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 1em;
overflow: hidden;
}
.photo-name { float: left; }
.photo-date { float: right; }
.photo-section {
border: 1px solid #cacece;
overflow: hidden;
}
<div class='photo-setup'>
<div class='setup-head'>
<div class='photo-name'>Photo Name : <input type='text' placeholder='Photo Name' name='photo-name' title='Photo Name'></div>
<div class='photo-date'>Photo Date : <?php echo date('F j, o', time()) ?></div>
</div>
<div class='photo-section'>
<img src='http://placehold.it/600/eee' width='600' height='600' alt='photo'>
</div>
<div class='tag-section'>
Tags : <input type='text' placeholder='Tags e.g. (#beach #park #dog)'>
</div>
<div class='commit-section'>
<a class='save' href='#'>Save</a><a class='cancel' href='#'>Cancel</a>
</div>
</div>
Questions 1:
You have a float left and float right on photo-name and photo-date as such taken out of the normal flow, you have to add overflow:auto to the parent class so it does not lose its padding state.
img { border: none; }
.photo-setup {
width: 600px;
height: auto;
margin: 0 auto;
}
.setup-head {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
border-top: 1px solid #cacece;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 1em;
overflow: auto;
}
.photo-name { float: left; }
.photo-date { float: right; }
.photo-section {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
}
<!-- start setup section -->
<div class='photo-setup'>
<div class='setup-head'>
<div class='photo-name'>Photo Name : <input type='text' placeholder='Photo Name' name='photo-name' title='Photo Name'></div>
<div class='photo-date'>Photo Date : <?php echo date('F j, o', time()) ?></div>
</div>
<div class='photo-section'>
<img src='' width='600' height='600' alt='photo'>
</div>
<div class='tag-section'>
Tags : <input type='text' placeholder='Tags e.g. (#beach #park #dog)'>
</div>
<div class='commit-section'>
<a class='save' href='#'>Save</a><a class='cancel' href='#'>Cancel</a>
</div>
</div>
<!-- end setup section-->
Question 2: It is the img childs border which the browser adds to it if there is not a src for it and can not be overridden. Easy fix for you though is to remove (as you already have a border round the image)
.photo-section {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
}
from your code
img { border: none; }
.photo-setup {
width: 600px;
height: auto;
margin: 0 auto;
}
.setup-head {
border-left: 1px solid #cacece;
border-right: 1px solid #cacece;
border-top: 1px solid #cacece;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 1em;
overflow: auto;
}
.photo-name { float: left; }
.photo-date { float: right; }
<!-- start setup section -->
<div class='photo-setup'>
<div class='setup-head'>
<div class='photo-name'>Photo Name : <input type='text' placeholder='Photo Name' name='photo-name' title='Photo Name'></div>
<div class='photo-date'>Photo Date : <?php echo date('F j, o', time()) ?></div>
</div>
<div class='photo-section'>
<img src='' width='600' height='600' alt='photo'>
</div>
<div class='tag-section'>
Tags : <input type='text' placeholder='Tags e.g. (#beach #park #dog)'>
</div>
<div class='commit-section'>
<a class='save' href='#'>Save</a><a class='cancel' href='#'>Cancel</a>
</div>
</div>
<!-- end setup section-->
Add overflow: hidden; to .setup-head or clear your floats.
They are the same. You see a 2px border because the image is missing.
On http://adasportsandrackets.com/wordpress, I am trying to add CSS to add a border under the h4 heading "Best Sellers." It's not working and it's not a caching issue as I've tried in the major browsers after deleting cache.
Here is the HTML:
<div class="wpb_text_column wpb_content_element best-sellers">
<div class="wpb_wrapper">
<h4>Best Sellers</h4>
And here is my CSS:
.best-sellers h4 {
border-bottom: 1px solid #eee;
padding: 7px 0px;
}
I also tried:
.best-sellers {
border-bottom: 1px solid #eee;
padding: 7px 0px;
}
This worked for me:
.page-template-template-home-default-php .wpb_wrapper h4 {
border-bottom: 5px solid #999;
}
Or try:
.best-sellers h4 {border-bottom: 5px solid #999;}
Try:
.wpb_wrapper h4 { border-bottom: 1px solid #eeeeee;}
Or try adding a class to h4 e.g.
<h4 class="borderh4">Lol</h4>
.borderh4 {border-bottom: 1px solid #eeeeee;}
Best to select based on it's parent div class:
.wpb_wrapper h4 {
border-bottom: 1px solid #eee;
padding: 7px 0px;
}
As the previous answer stated, if your parent div has multiple classes, you usually need to select both for it to grab the right element:
.wpb_wrapper.another_class h4 {}
I want to create a border as shown in the image. I tried with all the styles inset, outset,ridge and groove but I was not able to get the expected result.
Is there any way to bend border towards inside till middle and get back towards till top(hope you understand the problem).
If it's repeated question please add the solution link.
Thanks in advance.
I have tried this:
div {
border-bottom: 1px ridge #B5B9BB;
/*border-bottom: 1px inset #B5B9BB;
border-bottom: 1px outset #B5B9BB;
border-bottom: 1px groove #B5B9BB; */
}
You could use outline:
.bordered {
border-bottom: 1px solid grey;
background: aliceblue;
outline: 5px solid aliceblue;
}
<div class="bordered">Available Apps</div>
Demo
Seems why not just use a border on the text?
div {
background: lightgrey;
padding: 0.5em;
}
p {
border-bottom: 1px ridge #B5B9BB;
}
<div>
<p>Available Apps</p>
</div>
It is probably best to use a wrapping element if possible; it is more flexible than outline (supports border-radius, box-shadows etc.)
For example:
<div class="headline-area">
<h2>Available Apps</h2>
</div>
with the CSS:
.headline-area {
background:#D4D9DC;
padding:5px;
}
.headline-area h2 {
border-bottom:1px solid #B5B9BB;
}
Whenever I am in your situation I use box-shadow:
body {
background:#D1D6D9;
font-family:verdana;
}
div {
border-bottom: 1px solid #B5B9BB;
box-shadow:0 1px 1px rgba(255,255,255,.7);
padding-bottom:5px;
}
<div>Available Apps</div>
You could always try a hr tag. You can then style it in CSS to your desired preference.
HTML
New apps
<hr>
Try this Also but you need an extra Div to do so.
HTML
<div class="outerDiv">
COntent
<div class="innerDiV">
</div>
<div>
CSS
.outerDiv{
background-color: grey;
height: 32px;
text-align: center;
padding: 16px;
font-weight: bolder;
font-size: 25px;
}
.innerDiV{
margin: 0 auto;
border: 1px solid black;
width: 98%;
margin-top: 10px;
}
Demo
I want to create a table grid using DIV (HTML & CSS only). I almost got into and still got some issues. I attached the sample image. I want the grid should be the same like this sample image. I attached the fiddle of what I created so far. Could you help somebody that what am doing and how can I improve to finish the table as same as the image?
HTML:
<div class="containerDiv">
<div class="rowDivHeader">
<div class="cellDivHeader">Recommendation</div>
<div class="cellDivHeader">Typical savings</div>
<div class="cellDivHeader">Improved SAP</div>
<div class="cellDivHeader">Improved EI</div>
<div class="cellDivHeader">Indicative cost</div>
<div class="cellDivHeader">Include</div>
<div class="cellDivHeader lastCell">Removal Reason</div>
</div>
<div class="rowDiv">
<div class="cellDiv">Room-in-roof-insulation</div>
<div class="cellDiv">93.0</div>
<div class="cellDiv">F : 29</div>
<div class="cellDiv">B : 89</div>
<div class="cellDiv">£1,500 - £2,700</div>
<div class="cellDiv">Checkbox</div>
<div class="cellDiv lastCell">Textbox</div>
</div>
</div>
CSS:
.containerDiv {
border: 1px solid #3697f6;
width: 100%;
}
.rowDivHeader {
border: 1px solid #668db6;
background-color: #336799;
color: white;
font-weight: bold;
}
.rowDiv {
border: 1px solid #668db6;
background-color: #cee6fe;
}
.cellDivHeader {
border-right: 1px solid white;
display: table-cell;
width:12%;
padding: 1px;
text-align: center;
}
.cellDiv {
border-right: 2px solid white;
display: table-cell;
width:10%;
padding-right: 4px;
text-align: center;
border-bottom: none;
}
.lastCell {
border-right: none;
}
sample image
Add display:table-row to the row div i.e .rowDivHeader & .rowDiv
& display:table to the main div .containerDiv
.containerDiv {
border: 1px solid #3697f6;
width: 100%; display:table
}
.rowDivHeader {
border: 1px solid #668db6;
background-color: #336799;
color: white;
font-weight: bold; display:table-row
}
.rowDiv {
border: 1px solid #668db6;
background-color: #cee6fe;
display:table-row
}
DEMO