How to Merge Two Divs

How to merge two divs

Maybe try something like this: http://jsfiddle.net/VNAZA/

Uses two divs: one with just the border, which gets layered under the rectangle and another with the actual content, layering over the rectangle. This way you can also apply css box-shadow to the lower div.

.container{
position:relative;
width: 50px;
height: 150px;
}

.rect{
position:absolute;
width: 50px;
height: 150px;
background: #eee;
border: 1px solid #000;
z-index: 5;
-webkit-box-shadow: 2px 2px 10px 2px #cccccc;
box-shadow: 2px 2px 10px 2px #cccccc;
}

.round_content{
position: absolute;
top: 50px;
right: -25px;
width: 50px;
line-height: 50px;
background: #eee;
z-index: 6;
text-align:center;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}

.round_border{
position: absolute;
top: 49px;
right: -26px;
width: 52px;
height: 50px;
line-height: 52px;
border: 1px solid #000;
z-index: 4;
text-align: center;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 2px 2px 10px 2px #cccccc;
box-shadow: 2px 2px 10px 2px #cccccc;
}
    <div class="container"> 
<div class="rect"></div>
<div class="round_content">x</div>
<div class="round_border"></div>
</div>

How can I merge two adjacent DIVs into one?

Using DOM methods, a simplified example could be:

// ref .box-1 and .box-2

const box1 = document.querySelector('.box-1');

const box2 = document.querySelector('.box-2');

// move all child nodes from box2 to box1

// Array.from (or any method to copy a *live* DOM NodeList) is needed,

// for otherwise the DOM manipulation would throw off the loop

Array.from(box2.childNodes).forEach(child => box1.appendChild(child));

// afterwards, remove box2

box2.parentNode.removeChild(box2);
<div class="box-1">

<span>A</span>

B

</div>

<div class="box-2">

<span>C</span>

D

</div>

How to merge two divs and put header on every roww in a table

If you are using bootstrap v4 you can add a no-gutters class on the row, if not you can add a new class to remove the default padding from columns like this:

.padding-0{
padding-right:0;
padding-left:0;
}

In version 3.4 you also have a class you can add to the row called row-no-gutters

How to merge two divs styles?

The html

<div id=parent style="font-size:12px; color:red">
<div id="child" style="color:blue">text</div>
</div>

I added IDs just to make it easy to grab those elements, there are many other ways to do it as well.

and here's the JS

parentClass = document.getElementById("parent").style.cssText;
childClass = document.getElementById("child").style.cssText;

document.getElementById("parent").style.cssText = parentClass+childClass;

Wrote the code in a very easy to understand style. Now the parent element will have both the classes of parent and child. If any of the classes repeat, then the styles of the child class will be applied, since it's written last (that's just how CSS works).

Finally, if you want, you can use removeChild() to remove the child element.

Merge two div to have same linear-gradient and shadow

You can do it like below:

body {
margin: 0;
}

.navContainer {
width: 100vw;
filter: drop-shadow(0px 5px 8px rgba(0, 0, 0, 0.45)); /* filter on main container */
}

.mainNav {
background:
linear-gradient(#30355e 0%, #383e6e 100%)
top/100% 110px; /* 110px = height of circle */
height: 75px;
border-radius: 0 0 40px 40px;
}

.circleNav {
width: 110px;
height: 110px;
background: linear-gradient(#30355e 0%, #383e6e 100%);
border-radius: 50%;
margin: -75px auto 0; /* same as height of nav */
}
<div class="navContainer">
<div class="mainNav">
</div>
<div class="circleNav">
</div>
</div>

How to merge div cells

Something like this?

.dtable { 

display:table;

table-layout: fixed;

width:529px;

}

.drow {

display:table-row;

width:525px;

}

.dcell {

display:table-cell;

border:1px solid gray;

}

#D_Cell_1 {

width:100px;

}

#Description {

width:100px;

height:58px;

}

#Des_Content{

overflow-y: scroll;

word-wrap: break-word;

position: absolute;

height:58px;

width:425px;

}
<div id='main_wrapper' class='dtable'>

<div id='control_panel_wrapper' class='drow'>

<div id='D_Cell_1' class='dcell'>Title</div>

<div id='D_Cell_2' class='dcell'>Manager marketing</div>

<div id='D_Cell_3' class='dcell'>Application Deadline</div>

<div id='D_Cell_4' class='dcell'>22.04.2012</div>

</div>

</div>

<div class='dtable'>

<div id='bottom_wrapper' class='drow'>

<div id='Description' class='dcell'>Description</div>

<div id='Des_Content' class='dcell'>LOREM IPSUM

dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</div>

</div>

</div>

Merge two divs with same gradient background

Use mask to create the shape:

.box {
height:100px;
border-bottom:50px solid transparent; /* this is the space for your circle */
background:linear-gradient(45deg,red,blue) border-box;
-webkit-mask:
linear-gradient(#fff 0 0) padding-box,
radial-gradient(circle farthest-side,#fff 98%,transparent)
bottom 0 left 50px /* position of circle */
/160px 160px /*size of circle */
no-repeat ;
}
<div class="box"></div>

merge divs with same value

You can do it the following way by creating a groupBy pipe and including Bootstrap 4 in the project. Here is a plain working demo (you will have to do the styling) demo:

groupby.pipe.ts

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({name: 'groupBy'})
export class GroupByPipe implements PipeTransform {
transform(collection: any[], property: string): any[] {
// prevents the application from breaking if the array of objects doesn't exist yet
if(!collection) {
return null;
}

const groupedCollection = collection.reduce((previous, current)=> {
if(!previous[current[property]]) {
previous[current[property]] = [current];
} else {
previous[current[property]].push(current);
}

return previous;
}, {});

// this will return an array of objects, each object containing a group of objects
return Object.keys(groupedCollection).map(key => ({ key, value: groupedCollection[key] }));
}
}

html code

<div class="table table-borderless ">
<div class="col-md-12 text-center border"><span>{{currentMonthName}}</span>  <span>{{currentYear}}</span></div>

<div class="d-flex">
<div class=" text-center m-2 border" *ngFor="let day of days | groupBy:'weekNumber'">
{{day.key}}
<table class="table">
<tbody>
<tr>
<th scope="row" *ngFor="let x of day.value ">{{x.number}}</th>
</tr>
<tr>
<th scope="row" *ngFor="let y of day.value ">{{y.name}}</th>
</tr>

</tbody>
</table>
</div>
</div>

</div>


Related Topics



Leave a reply



Submit